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

NPE in DefaultHttpClient with Proxy and AuthCache

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 4.3.3
    • 4.3.4
    • HttpClient (classic)
    • None

    Description

      For various reasons we are still using the now deprecated DefaultHttpClient. After updating to 4.3 we encountered a NullPointerException in a seldom case involving proxies and AuthCache.

          @Test
          public void testDefaultHttpClientProxyAndAuthCache() throws Exception {
              try (CloseableHttpClient client = new DefaultHttpClient()) {
                  ConnRouteParams.setDefaultProxy(client.getParams(), URIUtils.extractHost(URI.create("http://example.org")));
                  HttpClientContext context = HttpClientContext.create();
                  context.setAuthCache(new BasicAuthCache());
      //          java.lang.NullPointerException (null route)
      //          at org.apache.http.client.protocol.RequestAuthCache.process(RequestAuthCache.java:88)
      //          at org.apache.http.protocol.ImmutableHttpProcessor.process(ImmutableHttpProcessor.java:131)
                  HttpResponse resp = client.execute(new HttpGet("https://www.example.org"), context);
                  EntityUtils.consumeQuietly(resp.getEntity());
              }
          }
      

      Thanks in Advance.

      Attachments

        Activity

          People

            Unassigned Unassigned
            mkull Markus Kull
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: