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

HttpConnection should resolve addresses before SocketChannel.connect() is called

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 10
    • Fix Version/s: 10
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b20

      Description

      The following exception can occur when using ProxySelector.getDefault();

              ProxySelector ps = ProxySelector.getDefault();
              HttpClient client = HttpClient.newBuilder()
                  .version(HttpClient.Version.HTTP_1_1)
                  .proxy(ps)
                  .build();
              HttpRequest request = HttpRequest.newBuilder()
                  .GET()
                  .uri(new URI("https://www.oracle.com/"))
                  .build();

              HttpResponse<String> response
                  = client.send(request, HttpResponse.BodyHandler.asString());
              System.out.println(response.body());


      Exception in thread "main" java.nio.channels.UnresolvedAddressException
      at java.base/sun.nio.ch.Net.checkAddress(Net.java:112)
      at java.base/sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:622)
      at jdk.incubator.httpclient/jdk.incubator.http.PlainHttpConnection.connect(PlainHttpConnection.java:151)
      at jdk.incubator.httpclient/jdk.incubator.http.PlainTunnelingConnection.connect(PlainTunnelingConnection.java:74)
      at jdk.incubator.httpclient/jdk.incubator.http.SSLTunnelConnection.connect(SSLTunnelConnection.java:53)
      at jdk.incubator.httpclient/jdk.incubator.http.Http1Exchange.sendHeadersOnly(Http1Exchange.java:134)
      at jdk.incubator.httpclient/jdk.incubator.http.Exchange.responseImpl0(Exchange.java:297)
      at jdk.incubator.httpclient/jdk.incubator.http.Exchange.responseImpl(Exchange.java:245)
      at jdk.incubator.httpclient/jdk.incubator.http.Exchange.response(Exchange.java:121)
      at jdk.incubator.httpclient/jdk.incubator.http.MultiExchange.response(MultiExchange.java:154)
      at jdk.incubator.httpclient/jdk.incubator.http.HttpClientImpl.send(HttpClientImpl.java:234)

        Attachments

          Activity

            People

            Assignee:
            dfuchs Daniel Fuchs
            Reporter:
            dfuchs Daniel Fuchs
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: