Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6797318

Undeclared IAE thrown from HttpURLConnection.connect for some URLs

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 5.0
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      linux

      Description

      Run:

      ---%<---
      import java.io.IOException;
      import java.net.URL;
      public class ProxyIAETest {
          public static void main(String[] args) {
              connect("http://localhost/nonexistent");
              connect("http:///");
          }
          private static void connect(String url) {
              System.out.println("Connecting to: " + url);
              try {
                  new URL(url).openConnection().connect();
              } catch (IOException x) {
                  System.out.println("OK, got expected exception: " + x);
              }
          }
      }
      ---%<---

      I get:

      ---%<---
      java version "1.7.0-ea"
      Java(TM) SE Runtime Environment (build 1.7.0-ea-b43)
      Java HotSpot(TM) Server VM (build 14.0-b10, mixed mode)

      Connecting to: http://localhost/nonexistent
      OK, got expected exception: java.net.ConnectException: Connection refused
      Connecting to: http:///
      Exception in thread "main" java.lang.IllegalArgumentException: protocol = http host = null
              at sun.net.spi.DefaultProxySelector.select(DefaultProxySelector.java:164)
              at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:758)
              at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:688)
              at ProxyIAETest.connect(ProxyIAETest.java:11)
              at ProxyIAETest.main(ProxyIAETest.java:6)
      ---%<---

      (Similar on JDK 5, 6.)

      Of course the URL cannot be connected to. But this should result in an IOException of some kind, not an IllegalArgumentException.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              chegar Chris Hegarty
              Reporter:
              jglick Jesse Glick (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: