Description
When sending a conditional request and the cache entry does not have an entity, CachingHttpClient throws a NullPointerException.
To reproduce :
- send a first conditional If-None-Match request and receive a first 304 that generates a cache entry with no entity
- send a second conditional request and receive another 304
When updating the cache entry, CachingHttpClient tries to copy the entity of the existing cache entry without testing if it is null.
Here is a test to reproduce :
@Test
public void testNotModifiedResponseUpdatesCacheEntryWhenNoEntity()
throws Exception
And here is what you get:
java.lang.NullPointerException
at org.apache.http.impl.client.cache.HeapResourceFactory.copy(HeapResourceFactory.java:73)
at org.apache.http.impl.client.cache.CacheEntryUpdater.updateCacheEntry(CacheEntryUpdater.java:90)
at org.apache.http.impl.client.cache.BasicHttpCache.updateCacheEntry(BasicHttpCache.java:214)
at org.apache.http.impl.client.cache.CachingExec.revalidateCacheEntry(CachingExec.java:752)
at org.apache.http.impl.client.cache.CachingExec.revalidateCacheEntry(CachingExec.java:318)
at org.apache.http.impl.client.cache.CachingExec.handleCacheHit(CachingExec.java:288)
at org.apache.http.impl.client.cache.CachingExec.execute(CachingExec.java:266)
at org.apache.http.impl.client.cache.CachingExec.execute(CachingExec.java:219)
at org.apache.http.impl.client.cache.TestCachingExec.testNotModifiedResponseUpdatesHeadersInCacheWhenNoEntity(TestCachingExec.java:1591)