javatcpapache-httpclient-4.xapache-httpcomponents

Why the stale connection check is not 100% reliable in apache httpclient connectionPool


In section 2.5. Connection eviction policy of the documentation connection managment doc for httpclient mentions that

HttpClient tries to mitigate the problem by testing whether the connection is 'stale', that is no longer valid because it was closed on the server side, prior to using the connection for executing an HTTP request. The stale connection check is not 100% reliable.

I am just wondering why stale connection cant be checked reliably ? What logical/TCP construct dont allow it to happen reliably?


Solution

  • It is trivial. There is always a window of time, however small, between the successful stale check and request execution, in which the opposite endpoint can close the connection on its end and make the connection stale on the client end.