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

HttpClient.request() will always throw NPE

XMLWordPrintable

    • generic
    • generic

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

      A DESCRIPTION OF THE PROBLEM :
      Using the request()-method on HttpClient without specifying a URI will always throw NPE, as the implementation

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a HttpRequest.Builder using the no-param request-method on HttpClient

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      HttpRequest.Builder is created
      ACTUAL -
      NullPointerException is thrown from HttpRequestBuilderImpl.checkURI

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "main" java.lang.NullPointerException
      at java.net.http.HttpRequestBuilderImpl.checkURI(java.httpclient@9-ea/HttpRequestBuilderImpl.java:70)
      at java.net.http.HttpRequestBuilderImpl.<init>(java.httpclient@9-ea/HttpRequestBuilderImpl.java:48)
      at java.net.http.HttpClientImpl.request(java.httpclient@9-ea/HttpClientImpl.java:420)
      at java.net.http.HttpClientImpl.request(java.httpclient@9-ea/HttpClientImpl.java:61)
      at java9.HttpClientMain.main(HttpClientMain.java:22)




      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
                  HttpClient.getDefault()
                      .request()
                      .uri(URI.create("http://www.example.com"))
                      .GET();
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
                  HttpClient.getDefault()
                      .request(URI.create("http://www.example.com"))
                      .GET();

            dfuchs Daniel Fuchs
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: