Description
We have experienced a problem with CachingHttpClient when we are connecting to a server cluster with times out of sync, and therefore providing response dates which are out of sync.
This causes a problem because during cache revalidation, if it gets a revalidation response which is deemed "too old" it will make a second unconditional request (as per the spec i believe). The issue is that the first response isn't properly consumed so that the connection remains open. Its file handle remains and the connection is never released back to the pool, so the pool eventually fills up.
This can be fixed by ensuring the first response is consumed, e.g. replace CachingHttpClient line 717 with -
if (respDate.before(entryDate)) {
try
catch (IOException e)
{ log.warn("Problem consuming old validation response"); } return true;
}
The issue can be reproduced / tested using a HttpResponseInterceptor that randomly changes the Date header (and hitting a page that both allows revalidation and changes content)