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

ClassCastException when performing a HTTP2 request though proxy

XMLWordPrintable

    • x86_64
    • windows

      FULL PRODUCT VERSION :
      java version "9.0.4"
      Java(TM) SE Runtime Environment (build 9.0.4+11)
      Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.16299.309]

      A DESCRIPTION OF THE PROBLEM :
      Send a HTTPS request though a proxy connection based on HTTP_2 protocol throws ClassCastException

      "
      java.lang.ClassCastException: jdk.incubator.httpclient/jdk.incubator.http.SSLTunnelConnection cannot be cast to jdk.incubator.httpclient/jdk.incubator.http.AsyncConnection
      "

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Execute the source code below

      ACTUAL -
      java.lang.ClassCastException

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.lang.ClassCastException: jdk.incubator.httpclient/jdk.incubator.http.SSLTunnelConnection cannot be cast to jdk.incubator.httpclient/jdk.incubator.http.AsyncConnection

      at jdk.incubator.httpclient/jdk.incubator.http.Http2Connection.<init>(Http2Connection.java:270)
      at jdk.incubator.httpclient/jdk.incubator.http.Http2ClientImpl.getConnectionFor(Http2ClientImpl.java:108)
      at jdk.incubator.httpclient/jdk.incubator.http.ExchangeImpl.get(ExchangeImpl.java:86)
      at jdk.incubator.httpclient/jdk.incubator.http.Exchange.establishExchange(Exchange.java:257)
      at jdk.incubator.httpclient/jdk.incubator.http.Exchange.responseImpl0(Exchange.java:268)
      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)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      somewhatHttpClient.send(
      HttpRequest
      .newBuilder()
      .uri(URI.create("https://www.google.com"))
      .GET()
      .version(HttpClient.Version.HTTP_2)
      .build(),
      HttpResponse.BodyHandler.asString()
      );
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      DROP module jdk.incubator.httpclient

            psonal Pallavi Sonal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: