Uploaded image for project: 'HttpComponents HttpClient'
  1. HttpComponents HttpClient
  2. HTTPCLIENT-1296

Null pointer exception when using default host and virtual host with port -1

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 4.2.2
    • 4.2.3
    • None
    • None

    Description

      The following code in DefaultRequestDirector is incorrect:

              // HTTPCLIENT-1092 - add the port if necessary
              if (virtualHost != null && virtualHost.getPort() == -1) {
                  int port = target.getPort();
                  if (port != -1){
                      virtualHost = new HttpHost(virtualHost.getHostName(), port, virtualHost.getSchemeName());
                  }
              }
      

      The reason it is incorrect is that if the target has not been specified in the URL, then an NPE will result. The target is resolved later in the same method in that case.

      Attachments

        1. HTTPCLIENT-1296.patch
          3 kB
          Karl Wright

        Activity

          People

            kwright@metacarta.com Karl Wright
            kwright@metacarta.com Karl Wright
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: