hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Issue with Http OPTIONS request and htt-client-cache
Date Mon, 16 Nov 2015 16:06:07 GMT
On Mon, 2015-11-16 at 15:16 +0000, THIL Laurent (CAP-GEMINI) wrote:
> We have http requests of type OPTIONS that hit the CachingHttpClient that return in exception.
I put a stack trace below:
> 
> java.lang.NullPointerException
>        at org.apache.http.impl.client.cache.RequestProtocolCompliance.addContentTypeHeaderIfMissing(RequestProtocolCompliance.java:187)
>        at org.apache.http.impl.client.cache.RequestProtocolCompliance.verifyOPTIONSRequestWithBodyHasContentType(RequestProtocolCompliance.java:183)
>        at org.apache.http.impl.client.cache.RequestProtocolCompliance.makeRequestCompliant(RequestProtocolCompliance.java:106)
>        at org.apache.http.impl.client.cache.CachingHttpClient.execute(CachingHttpClient.java:423)
>        at org.esigate.cache.CacheAdapter$HttpClientWrapper.execute(CacheAdapter.java:128)
>        at org.esigate.http.HttpClientHelper.execute(HttpClientHelper.java:238)
>        at org.esigate.Driver.executeSingleRequest(Driver.java:440)
>        at org.esigate.Driver.execute(Driver.java:444)
>        at org.esigate.Driver.proxy(Driver.java:225)
>        at org.esigate.servlet.AggregatorServlet.service(AggregatorServlet.java:85)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
> 
> 
> The problem seem to lie in method addContentTypeHeaderIfMissing:
> 
> private void addContentTypeHeaderIfMissing(final HttpEntityEnclosingRequest request)
{
>         if (request.getEntity().getContentType() == null) {
>             ((AbstractHttpEntity) request.getEntity()).setContentType(
>                     ContentType.APPLICATION_OCTET_STREAM.getMimeType());
>         }
> }
> 
> The line  'if (request.getEntity(). ' will return null, because there is no entity in
a OPTIONS request, from there the null pointer exception.
> In the case of a GET request to the CachingHttpClient, the field entity is null as well,
but were not running in 'verifyOPTIONSRequestWithBodyHasContentType ...
> 
> Is this behavior expected - we are missing something,  or truly a bug.
> 
> We are currently running httpclient 4.2.5,  but I see the same code in the trunk of the
project.
> 
> Thanks.

Please raise a JIRA for this defect and include a test case reproducing
the issue. TestRequestProtocolCompliance might be a good place to look
for existing test cases.

Oleg



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message