sonatype/nexus — pull request #563 by cstamas (2012-10-05 13:05:25+00:00)
Title: NEXUS-5292: Implemented connection eviction

* Introduced a new daemon thread that monitor and performs pool eviction on regular time intervals (5s). This is the proposed pattern by ASF HttpClient4x, to implement an external monitor thread, as HC4 does not have any other "internal" eviction mechanism. It can "check stale connection" per processed request, that introduces 30-40ms overhead per HTTP request, and still, if no outbound request happens in nexus, no eviction will happen.
* HttpClientUtil class improved, extracted some reusable non-proxy specific methods, applied some recommended changes and fixed problems: proxy authorisation was overriding target authorisation, also, a warning message was present (as the code originates from HC3 support class) that NTLM is unsupported for Proxies when other scheme is used for target. This is untrue for HC4x.
* the three introduced parameters are exposed to users (pool size, pool timeout and pool keep-alive), default values are poolSize=20, poolKeepAlive=1minute and poolTimeout=poolKeepAlive. Users might override defaults by setting system properties.

Based on comments made by JD, some generic (non proxy repository specific) methods for HttpClient creation and releasing were made public. This means, that this class
might be used as "generic" HTTPClient4x factory, to create instances preconfigured and obeying Nexus config (like use of globally configured proxy etc).

Still, historically this class was made (intended to be?) a simple static utility class, but today it is growing. Probably the best would be to factor out the "hc factory" parts into a component, pulled out from this package (as it would be nor remote storage nor proxy specific) and this static class removed completely.

Existing class UT extended with eviction test and configuration discovery tests.