Proxy EOF detection. #705

Merged
merged 7 commits into from Mar 15, 2013

Conversation

Projects
None yet
3 participants
Contributor

cstamas commented Dec 14, 2012

Issue NXCM-4864 revealed that pull request
#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
#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.

Proxy EOF detection.
Issue NXCM-4864 revealed that pull request
#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
#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.
Contributor

adreghiciu commented Dec 17, 2012

UT/IT ?

+1 beside above

+ * @author cstamas
+ * @since 2.4
+ */
+public class RemoteStorageEofException
@peterlynch

peterlynch Jan 2, 2013

Member

Poorly named - 'EofException' reads as E of Exception to me - could argue RemoteStorageEOFException is more consistent at least with JDK and acceptable - but would it be so bad to use 'RemoteStorageEndOfFileException' I wonder

Same with Local...

cstamas added some commits Feb 5, 2013

Merge remote-tracking branch 'origin/master' into proxy-eof
Conflicts:
	nexus/nexus-proxy/src/main/java/org/sonatype/nexus/proxy/storage/remote/httpclient/HttpClientRemoteStorage.java
Added UT.
Also, fetch did not propagate EOF exception.
Keep original comment in code.
To have trail why we do not abort in close method
Contributor

cstamas commented Feb 6, 2013

Applied comments, added UT for this case (remote drops connection during proxy caching).

cstamas added a commit that referenced this pull request Mar 15, 2013

@cstamas cstamas merged commit 657f969 into master Mar 15, 2013

@cstamas cstamas deleted the proxy-eof branch Mar 15, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment