question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NPE with httpclient 4.4

See original GitHub issue
Caused by: java.lang.NullPointerException
    at java.io.FilterInputStream.read(FilterInputStream.java:133)
    at com.fasterxml.jackson.core.json.ByteSourceJsonBootstrapper.ensureLoaded(ByteSourceJsonBootstrapper.java:489)
    at com.fasterxml.jackson.core.json.ByteSourceJsonBootstrapper.detectEncoding(ByteSourceJsonBootstrapper.java:126)
    at com.fasterxml.jackson.core.json.ByteSourceJsonBootstrapper.constructParser(ByteSourceJsonBootstrapper.java:215)
    at com.fasterxml.jackson.core.JsonFactory._createParser(JsonFactory.java:1191)
    at com.fasterxml.jackson.core.JsonFactory.createParser(JsonFactory.java:753)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2207)
    at org.ektorp.impl.StdCouchDbConnector$5.success(StdCouchDbConnector.java:250)
    at org.ektorp.http.RestTemplate.handleResponse(RestTemplate.java:122)
    at org.ektorp.http.RestTemplate.get(RestTemplate.java:22)
    at org.ektorp.impl.StdCouchDbConnector.get(StdCouchDbConnector.java:246)
    at org.ektorp.impl.StdCouchDbConnector.get(StdCouchDbConnector.java:237)
    at org.ektorp.support.StdDesignDocumentFactory.getFromDatabase(StdDesignDocumentFactory.java:57)
    at org.ektorp.support.CouchDbRepositorySupport.initDesignDocInternal(CouchDbRepositorySupport.java:280)
    at org.ektorp.support.CouchDbRepositorySupport.initStandardDesignDocument(CouchDbRepositorySupport.java:274)

This exception is thrown after upgrading httpclient from 4.3.6 to 4.4 (using Java8u31 and ektorp 1.4.2).

I reverted for now but wanted to inform you about this problem.

Issue Analytics

  • State:open
  • Created 9 years ago
  • Comments:25 (10 by maintainers)

github_iconTop GitHub Comments

4reactions
felixhallcommented, Apr 6, 2018

I ran into this when I upgraded Spring Boot 1.5 -> 2.0. It caused an upgrade of Jackson, which in turn forced me to upgrade to Ektorp 1.5, after which my “all”-views for designs stopped working with similar stack traces as @huxi above.

Solved it by disabling StdHttpClient.caching using Java configuration of Spring Boot, something like:

@Bean
public CouchDbConnector getCouchDb() throws Exception {
        StdHttpClient.Builder httpClientBuilder = new StdHttpClient.Builder();
        httpClientBuilder.url(getDatabaseUrl()).caching(false);  // <-- Here
        // (..)
        CouchDbConnector dbConnector = new StdCouchDbConnector(getDatabaseName(),
                new StdCouchDbInstance(httpClientBuilder.build()), omf);
        dbConnector.createDatabaseIfNotExists();
        return dbConnector;
}

Thanks @maratynsky !

0reactions
gesellixcommented, Apr 28, 2018

As of HttpClient-Cache 4.4+ HEAD requests will be cached. This seems to break in cases where the HEAD request comes first before any subsequent GET requests on the same target. In other words: if you can use httpclient-cache:4.3.x in your setup, you should be able to work around that issue. Details/demo see https://github.com/gesellix/httpclient-cache-demo. I’ve already started a discussion about that issue at the httpclient-users mailing list: https://lists.apache.org/thread.html/8cb4252482565e0f6d59b097320cfbf572c212508b63e9fc59a2e1b4@<httpclient-users.hc.apache.org> - feel free to join.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HttpClient 4.5.X release notes - Apache Distribution
HttpClient 4.5.5 (GA) is a maintenance release that fixes a regression introduced by the previous release causing a NPE in SystemDefaultCredentialsProvider.
Read more >
Cookies getting ignored in Apache httpclient 4.4 - java
I have executed the example code with both versions 4.3.6 and 4.5 . With 4.3.6 I used RequestConfig.DEFAULT and it was working fine....
Read more >
[jira] [Commented] (HTTPCORE-530) NullPointerException in ...
filterHeader(BasicListHeaderIterator.java:130) ~[Apache-HttpComponents-HttpCore-4.4.x.jar:?] at org.apache.http.message.
Read more >
ThreadingBehavior (Apache HttpCore 4.4.6 API) - Javadoc.io
... Throws: IllegalArgumentException - if this enum type has no constant with the specified name: NullPointerException - if the argument is null.
Read more >
org.apache.httpcomponents : httpclient : 4.4.1 - Maven Central
Apache HttpClient - Apache HttpComponents Client. ... org.apache.httpcomponents:httpclient 4.4.1. content_copy. <?xml version="1.0" encoding="UTF-8"?> <!
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found