Merge pull request #527 from garyrussell/INT-2635
* garyrussell-INT-2635: INT-2635 Set Buffer Size for Piped Streams
This commit is contained in:
@@ -82,7 +82,11 @@ public class TcpNioConnection extends AbstractTcpConnection {
|
||||
public TcpNioConnection(SocketChannel socketChannel, boolean server, boolean lookupHost) throws Exception {
|
||||
super(socketChannel.socket(), server, lookupHost);
|
||||
this.socketChannel = socketChannel;
|
||||
this.pipedInputStream = new PipedInputStream();
|
||||
int receiveBufferSize = socketChannel.socket().getReceiveBufferSize();
|
||||
if (receiveBufferSize <= 0) {
|
||||
receiveBufferSize = this.maxMessageSize;
|
||||
}
|
||||
this.pipedInputStream = new PipedInputStream(receiveBufferSize);
|
||||
this.pipedOutputStream = new PipedOutputStream(this.pipedInputStream);
|
||||
this.channelOutputStream = new ChannelOutputStream();
|
||||
}
|
||||
|
||||
@@ -264,6 +264,7 @@ public class TcpNioConnectionTests {
|
||||
return 1025;
|
||||
}
|
||||
}).when(channel).read(Mockito.any(ByteBuffer.class));
|
||||
when(socket.getReceiveBufferSize()).thenReturn(1024);
|
||||
final TcpNioConnection connection = new TcpNioConnection(channel, false, false);
|
||||
connection.setTaskExecutor(exec);
|
||||
connection.setPipeTimeout(200);
|
||||
|
||||
Reference in New Issue
Block a user