Streaming: Consistent exception message on socket close

This commit is contained in:
zzz
2018-01-20 11:34:16 +00:00
parent 08dec0e00d
commit d8c3f617aa
3 changed files with 12 additions and 12 deletions

View File

@@ -203,10 +203,10 @@ class Connection {
if (!_connected.get()) {
if (getResetReceived())
throw new I2PSocketException(I2PSocketException.STATUS_CONNECTION_RESET);
throw new IOException("disconnected");
throw new IOException("Socket closed");
}
if (_outputStream.getClosed())
throw new IOException("output stream closed");
throw new IOException("Output stream closed");
started = true;
// Try to keep things moving even during NACKs and retransmissions...
// Limit unacked packets to the window
@@ -785,7 +785,7 @@ class Connection {
_outputStream.destroy();
_receiver.destroy();
_activityTimer.cancel();
_inputStream.streamErrorOccurred(new IOException("disconnected"));
_inputStream.streamErrorOccurred(new IOException("Socket closed"));
if (_log.shouldLog(Log.INFO))
_log.info("Connection disconnect complete: "

View File

@@ -298,7 +298,7 @@ class MessageInputStream extends InputStream {
buf.append("not ready bytes: ").append(notAvailable);
buf.append(" highest ready block: ").append(_highestReadyBlockId);
_log.debug(buf.toString(), new Exception("closed"));
_log.debug(buf.toString(), new Exception("Input stream closed"));
}
_closeReceived = true;
_dataLock.notifyAll();
@@ -410,7 +410,7 @@ class MessageInputStream extends InputStream {
else
expiration = -1;
synchronized (_dataLock) {
if (_locallyClosed) throw new IOException("Already locally closed");
if (_locallyClosed) throw new IOException("Input stream closed");
throwAnyError();
for (int i = 0; i < length; i++) {
if ( (_readyDataBlocks.isEmpty()) && (i == 0) ) {
@@ -419,7 +419,7 @@ class MessageInputStream extends InputStream {
while (_readyDataBlocks.isEmpty()) {
if (_locallyClosed)
throw new IOException("Already closed");
throw new IOException("Input stream closed");
if ( (_notYetReadyBlocks.isEmpty()) && (_closeReceived) ) {
if (_log.shouldLog(Log.INFO))
@@ -524,7 +524,7 @@ class MessageInputStream extends InputStream {
public int available() throws IOException {
int numBytes = 0;
synchronized (_dataLock) {
if (_locallyClosed) throw new IOException("Already closed");
if (_locallyClosed) throw new IOException("Input stream closed");
throwAnyError();
for (int i = 0; i < _readyDataBlocks.size(); i++) {
ByteArray cur = _readyDataBlocks.get(i);

View File

@@ -114,7 +114,7 @@ class MessageOutputStream extends OutputStream {
@Override
public void write(byte b[], int off, int len) throws IOException {
if (_closed.get()) throw new IOException("Already closed");
if (_closed.get()) throw new IOException("Output stream closed");
if (_log.shouldLog(Log.DEBUG))
_log.debug("write(b[], " + off + ", " + len + ") ");
int cur = off;
@@ -122,7 +122,7 @@ class MessageOutputStream extends OutputStream {
long begin = _context.clock().now();
while (remaining > 0) {
WriteStatus ws = null;
if (_closed.get()) throw new IOException("closed underneath us");
if (_closed.get()) throw new IOException("Output stream closed");
// we do any waiting outside the synchronized() block because we
// want to allow other threads to flushAvailable() whenever they want.
// this is the only method that *adds* to the _buf, and all
@@ -131,7 +131,7 @@ class MessageOutputStream extends OutputStream {
// To simplify the code, and avoid losing data from shrinking the max size,
// we only update max size when current buffer is empty
final int maxBuffer = (_valid == 0) ? locked_updateBufferSize() : _currentBufferSize;
if (_buf == null) throw new IOException("closed (buffer went away)");
if (_buf == null) throw new IOException("Output stream closed");
if (_valid + remaining < maxBuffer) {
// simply buffer the data, no flush
System.arraycopy(b, cur, _buf, _valid, remaining);
@@ -342,7 +342,7 @@ class MessageOutputStream extends OutputStream {
synchronized (_dataLock) {
if (_buf == null) {
_dataLock.notifyAll();
throw new IOException("closed (buffer went away)");
throw new IOException("Output stream closed");
}
// if valid == 0 return ??? - no, this could flush a CLOSE packet too.
@@ -443,7 +443,7 @@ class MessageOutputStream extends OutputStream {
return;
}
_flusher.cancel();
_streamError.compareAndSet(null,new IOException("Closed internally"));
_streamError.compareAndSet(null, new IOException("Output stream closed"));
clearData(true);
}