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

ClassCastException in HTTP Client

XMLWordPrintable

    • b20

      Following test case fails

      import java.io.IOException;
      import java.net.InetSocketAddress;
      import java.net.ProxySelector;
      import java.net.URI;
      import java.net.URISyntaxException;
      import jdk.incubator.http.HttpClient;
      import jdk.incubator.http.HttpRequest;
      import jdk.incubator.http.HttpResponse;

      public class Get {
          public static void main(String[] args)
                  throws IOException, URISyntaxException, InterruptedException
          {
              //HttpClient client = HttpClient.newHttpClient();
              ProxySelector ps = ProxySelector.of(new InetSocketAddress("someproxy", 80));
              System.out.println(ps);
              HttpClient client = HttpClient.newBuilder()
                      .proxy(ps)
                      .build();
              System.out.println(client.proxy().orElse(null));

              HttpRequest request = HttpRequest.newBuilder()
                  .GET()
                  .uri(new URI("https://someuri/"))
                  .build();

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

      fails with ClassCastException.

      The CCE probably was introduced by the last change to this code base.

            dfuchs Daniel Fuchs
            michaelm Michael McMahon
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: