Fix test failures n LocalTransportThreadModelTest
testConcurrentMessageBufferAccess() assumes the outbound/inbound byte buffers are unbounded. Because PooledByteBuf is bounded, the test did not pass. The fix makes an assumption that ctx.flush() or fireInboundBufferUpdated() will make the next buffer consumed immediately, which is not the case in the real world. Under network congestion, a user will see IndexOutOfBoundsException if the user's handler implementation writes boundlessly into inbound/outbound buffers.
This commit is contained in:
parent
bf8345999c
commit
321b18d4d1
@ -436,8 +436,13 @@ public class LocalTransportThreadModelTest {
|
||||
|
||||
int expected = inCnt ++;
|
||||
Assert.assertEquals(expected, msg.intValue());
|
||||
if (out.maxCapacity() - out.writerIndex() < 4) {
|
||||
// Next inbound buffer is full - attempt to flush some data.
|
||||
ctx.fireInboundBufferUpdated();
|
||||
}
|
||||
out.writeInt(msg);
|
||||
}
|
||||
|
||||
ctx.fireInboundBufferUpdated();
|
||||
}
|
||||
|
||||
@ -534,7 +539,7 @@ public class LocalTransportThreadModelTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush(ChannelHandlerContext ctx,
|
||||
public void flush(final ChannelHandlerContext ctx,
|
||||
ChannelFuture future) throws Exception {
|
||||
Assert.assertSame(t, Thread.currentThread());
|
||||
|
||||
@ -549,8 +554,15 @@ public class LocalTransportThreadModelTest {
|
||||
|
||||
int expected = outCnt ++;
|
||||
Assert.assertEquals(expected, msg.intValue());
|
||||
|
||||
if (out.maxCapacity() - out.writerIndex() < 4) {
|
||||
// Next outbound buffer is full - attempt to flush some data.
|
||||
ctx.flush();
|
||||
}
|
||||
|
||||
out.writeInt(msg);
|
||||
}
|
||||
|
||||
ctx.flush(future);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user