jira-importer opened a new issue, #1434: URL: https://github.com/apache/httpcomponents-core/issues/1434
**[Adam Michalik](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=hattifnat)** opened **[HTTPCORE-437](https://issues.apache.org/jira/browse/HTTPCORE-437?redirect=false)** and commented I'm using HttpClient in multithreaded environment with PoolingHttpClientConnectionManager. Once in a while I get an exception whose root cause is ``` Caused by: java.lang.NullPointerException: null at org.apache.http.message.HeaderGroup.getHeaders(HeaderGroup.java:182) at org.apache.http.message.AbstractHttpMessage.getHeaders(AbstractHttpMessage.java:73) at org.apache.http.impl.client.DefaultClientConnectionReuseStrategy.keepAlive(DefaultClientConnectionReuseStrategy.java:51) at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:274) at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184) at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88) at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110) at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:220) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:164) ``` The `getHeaders` method is ```java public Header[] getHeaders(final String name) { List<Header> headersFound = null; for (int i = 0; i < this.headers.size(); i++) { final Header header = this.headers.get(i); if (header.getName().equalsIgnoreCase(name)) { // NPE HERE if (headersFound == null) { headersFound = new ArrayList<Header>(); } headersFound.add(header); } } return headersFound != null ? headersFound.toArray(new Header[headersFound.size()]) : EMPTY; } ``` I looked around in the `HeaderGroup` class and I see that every modification to the `headers` list has a null-check. Also, the `BasicHeader` and `BufferedHeader` have null-checks so that `name` cannot be null. How can this be occurring? The issue happens on production, around 10 exceptions in the last 12 hours out of 1 000 000 requests done in total. --- **Affects:** 4.4.5 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
