Fix IOExceptions swallowed by nested InputStream
Bug: 507300
Change-Id: I49c76b996609d8f938f019bb20a9ee2e4f1cf24d
Signed-off-by: Daniel Haftstein <haftsteind@gmail.com>
diff --git a/bundles/org.eclipse.epp.logging.aeri.ide/src/org/eclipse/epp/internal/logging/aeri/ide/server/mars/HttpResponses.java b/bundles/org.eclipse.epp.logging.aeri.ide/src/org/eclipse/epp/internal/logging/aeri/ide/server/mars/HttpResponses.java
index a57b664..9e31de3 100644
--- a/bundles/org.eclipse.epp.logging.aeri.ide/src/org/eclipse/epp/internal/logging/aeri/ide/server/mars/HttpResponses.java
+++ b/bundles/org.eclipse.epp.logging.aeri.ide/src/org/eclipse/epp/internal/logging/aeri/ide/server/mars/HttpResponses.java
@@ -254,32 +254,43 @@
}
@Override
+ public int hashCode() {
+ return stream.hashCode();
+ }
+
+ @Override
public int read() throws IOException {
+ checkCanceled();
+ progress.transferred(1);
+ return stream.read();
+ }
+
+ @Override
+ public int read(byte[] b) throws IOException {
+ checkCanceled();
+ int read = stream.read(b, 0, b.length);
+ progress.transferred(read);
+ return read;
+ }
+
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException {
+ // do not call super.read as long as this class inherits from InputStream
+ // inputstream.read(byte,int,int) will swallow all but the first IO exceptions, like SocketTimeouts
+ checkCanceled();
+ int read = stream.read(b, off, len);
+ progress.transferred(read);
+ return read;
+
+ }
+
+ private void checkCanceled() throws IOException {
if (progress.isMonitorCanceled()) {
if (stream instanceof ConnectionReleaseTrigger) {
((ConnectionReleaseTrigger) stream).abortConnection();
}
throw new CancellationException();
}
- progress.transferred(1);
- return stream.read();
- }
-
- @Override
- public int hashCode() {
- return stream.hashCode();
- }
-
- @Override
- public int read(byte[] b) throws IOException {
- // no progress, calls read()
- return super.read(b);
- }
-
- @Override
- public int read(byte[] b, int off, int len) throws IOException {
- // no progress, calls read()
- return super.read(b, off, len);
}
@Override