sonatype/nexus — pull request #705 by cstamas (2012-12-14 14:45:46+00:00)
Title: Proxy EOF detection.

Issue NXCM-4864 revealed that pull request
https://github.com/sonatype/nexus/pull/697
is insufficient to handle case when proxy remote peer
drops connection unexpectedly.

NXCM-4864 reveals what exact exception is thrown by HC4
when "remote peer" drops connection unexpectedly. Inspecting
the exception also reveals it is not an `java.io.EOFException`
descendant, but descends directly from `java.io.IOException`.
Hence, changes in pull request
https://github.com/sonatype/nexus/pull/697
(that kicks in on EOFException) will never kick in (and
this case will be handled as "generic IO problem" and will
auto block remote peer too).

So, we introduced a "wrapper" around the HC4 stream, to
have it "translate" HC4 specific exception
into one that is recognised (and handled) by Nexus Core.
Moreover, as it is highly likely that other transports will
use other exceptions (descending or not from EOFException),
using this technique we could always ensure that this case is
properly handled by Nexus Core.

Here, newly introduced Hc4InputStream is meant to translate
the `org.apache.http.ConnectionClosedException` thrown by
`org.apache.http.impl.io.ContentLengthInputStream` read methods.