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

java.net HTTP/2 client does not decrease stream count when receives 204 response

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b20
    • CPU:
      x86
    • OS:
      linux_redhat_7.0

      Backports

        Description

        ADDITIONAL SYSTEM INFORMATION :
        REH 7,6, Java 11.0.5

        A DESCRIPTION OF THE PROBLEM :
        java.net HTTP/2 client does not decrease stream count when receives 204 response and consequently the IOException "too many concurrent streams" will be thrown

        It is noted that 11.0.1 works with no problems

        REGRESSION : Last worked in version 11

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        1) Create an HTTP/2 server that returns 204 response
        2) Create a client that call the server continuously until an exception is thrown
        3) Start the server
        4) Start the client
        5) Observe the exception when the calls reaches the limit set by the server during HTTP/2 handshake

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        The client to call the server with no problems after reaching the limit
        ACTUAL -
        The IOException "too many concurrent streams" will be thrown

        ---------- BEGIN SOURCE ----------
        public class Http2clientApplicationTests {

        @Test
        public void test204() throws KeyManagementException, NoSuchAlgorithmException, IOException, InterruptedException {
                // Disable host name and cert verification.
                
                final Properties sysProps = System.getProperties();
                sysProps.setProperty("jdk.internal.httpclient.disableHostnameVerification", Boolean.TRUE.toString());
                sysProps.setProperty("jdk.internal.httpclient.debug",Boolean.TRUE.toString());
                SSLContext sslContext = SSLContext.getInstance("TLS");
                sslContext.init(null, new TrustManager[]{
                 new X509TrustManager() {
                 public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                 return null;
                 }
                 public void checkClientTrusted(
                 java.security.cert.X509Certificate[] certs, String authType) {
                 }
                 public void checkServerTrusted(
                 java.security.cert.X509Certificate[] certs, String authType) {
                 }
                 }
                 }, new SecureRandom());
                
                HttpClient client = HttpClient.newBuilder()
                 .version(Version.HTTP_2)
                 .sslContext(sslContext)
                 .build();
                
                HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create("https://localhost:8443/"))
        .DELETE()
        .build();

                try {
                 while (true) {
        HttpResponse<String> response = client.send(request, BodyHandlers.ofString());
        assertThat(response.statusCode() == 204);
                 }
                }
                catch (IOException ex) {
                 assertThat(ex.getMessage().equals("too many concurrent streams"));
                }

        }
        }

        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        use 11.0.1

        FREQUENCY : always

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                dfuchs Daniel Fuchs
                Reporter:
                tongwan Andrew Wang
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: