INT-1937 Fix NIO Connection State on Exception

This commit is contained in:
Gary Russell
2011-06-11 10:35:12 -04:00
parent c305d667a0
commit 9b626c946b

View File

@@ -258,25 +258,27 @@ public class TcpNioConnection extends AbstractTcpConnection {
}
this.writingToPipe = true;
if (this.taskExecutor == null) {
this.taskExecutor = Executors.newSingleThreadExecutor();
}
// If there is no assembler running, start one
checkForAssembler();
this.rawBuffer.clear();
int len = this.socketChannel.read(this.rawBuffer);
if (len < 0) {
try {
if (this.taskExecutor == null) {
this.taskExecutor = Executors.newSingleThreadExecutor();
}
// If there is no assembler running, start one
checkForAssembler();
this.rawBuffer.clear();
int len = this.socketChannel.read(this.rawBuffer);
if (len < 0) {
this.writingToPipe = false;
this.closeConnection();
}
this.rawBuffer.flip();
if (logger.isDebugEnabled()) {
logger.debug("Read " + rawBuffer.limit() + " into raw buffer");
}
this.pipedOutputStream.write(this.rawBuffer.array(), 0, this.rawBuffer.limit());
this.pipedOutputStream.flush();
} finally {
this.writingToPipe = false;
this.closeConnection();
}
this.rawBuffer.flip();
if (logger.isDebugEnabled()) {
logger.debug("Read " + rawBuffer.limit() + " into raw buffer");
}
this.pipedOutputStream.write(this.rawBuffer.array(), 0, this.rawBuffer.limit());
this.pipedOutputStream.flush();
this.writingToPipe = false;
}
private void checkForAssembler() {