diff --git a/apps/streaming/java/src/net/i2p/client/streaming/Connection.java b/apps/streaming/java/src/net/i2p/client/streaming/Connection.java index 5112600e8d89e2df144fa22e549cd2c8937d4636..dce484500cc8bd1548af3e10709976aa68f40f67 100644 --- a/apps/streaming/java/src/net/i2p/client/streaming/Connection.java +++ b/apps/streaming/java/src/net/i2p/client/streaming/Connection.java @@ -542,8 +542,9 @@ class Connection { _context.simpleScheduler().addEvent(new DisconnectEvent(), DISCONNECT_TIMEOUT); } _resetReceived = true; - _outputStream.streamErrorOccurred(new IOException("Reset received")); - _inputStream.streamErrorOccurred(new IOException("Reset received")); + IOException ioe = new IOException("Reset received"); + _outputStream.streamErrorOccurred(ioe); + _inputStream.streamErrorOccurred(ioe); _connectionError = "Connection reset"; synchronized (_connectLock) { _connectLock.notifyAll(); } } @@ -998,8 +999,9 @@ class Connection { _log.debug(buf.toString()); } - _inputStream.streamErrorOccurred(new IOException("Inactivity timeout")); - _outputStream.streamErrorOccurred(new IOException("Inactivity timeout")); + IOException ioe = new IOException("Inactivity timeout"); + _inputStream.streamErrorOccurred(ioe); + _outputStream.streamErrorOccurred(ioe); // Clean disconnect if we have already scheduled one // (generally because we already sent a close) disconnect(_disconnectScheduledOn >= 0); diff --git a/apps/streaming/java/src/net/i2p/client/streaming/MessageInputStream.java b/apps/streaming/java/src/net/i2p/client/streaming/MessageInputStream.java index eb168d11068325ab2257f91d655aa7448c619053..5767ec034ee01e4391de30a8573234183ccbeed8 100644 --- a/apps/streaming/java/src/net/i2p/client/streaming/MessageInputStream.java +++ b/apps/streaming/java/src/net/i2p/client/streaming/MessageInputStream.java @@ -465,10 +465,13 @@ class MessageInputStream extends InputStream { } private void throwAnyError() throws IOException { - if (_streamError != null) { - IOException ioe = _streamError; + IOException ioe = _streamError; + if (ioe != null) { _streamError = null; - throw ioe; + // constructor with cause not until Java 6 + IOException ioe2 = new IOException("Input stream error"); + ioe2.initCause(ioe); + throw ioe2; } } } diff --git a/apps/streaming/java/src/net/i2p/client/streaming/MessageOutputStream.java b/apps/streaming/java/src/net/i2p/client/streaming/MessageOutputStream.java index 4f7682dc91aa81aaeddd39288542ab5146ebb2f8..db317eab8812d58b77c5cae562dbbedb505875ce 100644 --- a/apps/streaming/java/src/net/i2p/client/streaming/MessageOutputStream.java +++ b/apps/streaming/java/src/net/i2p/client/streaming/MessageOutputStream.java @@ -446,10 +446,13 @@ class MessageOutputStream extends OutputStream { public boolean getClosed() { return _closed; } private void throwAnyError() throws IOException { - if (_streamError != null) { - IOException ioe = _streamError; + IOException ioe = _streamError; + if (ioe != null) { _streamError = null; - throw ioe; + // constructor with cause not until Java 6 + IOException ioe2 = new IOException("Output stream error"); + ioe2.initCause(ioe); + throw ioe2; } }