gaoyunhaii commented on a change in pull request #7368: [FLINK-10742][network] Let Netty use Flink's buffers directly in credit-based mode URL: https://github.com/apache/flink/pull/7368#discussion_r386797841
########## File path: flink-runtime/src/test/java/org/apache/flink/runtime/io/network/netty/CreditBasedPartitionRequestClientHandlerTest.java ########## @@ -419,6 +456,68 @@ public void testNotifyCreditAvailableAfterReleased() throws Exception { } } + @Test + public void testReceivedBufferForRemovedChannel() throws Exception { + final int bufferSize = 1024; + + NetworkBufferPool networkBufferPool = new NetworkBufferPool(10, bufferSize, 2); + SingleInputGate inputGate = createSingleInputGate(1); + RemoteInputChannel inputChannel = createRemoteInputChannel(inputGate, null, networkBufferPool); + inputGate.assignExclusiveSegments(); + + CreditBasedPartitionRequestClientHandler handler = new CreditBasedPartitionRequestClientHandler(); + handler.addInputChannel(inputChannel); + + try { + Buffer buffer = TestBufferFactory.createBuffer(bufferSize); + BufferResponse bufferResponse = createBufferResponse( + buffer, + 0, + inputChannel.getInputChannelId(), + 1, + new NetworkBufferAllocator(handler)); + + handler.removeInputChannel(inputChannel); + handler.channelRead(null, bufferResponse); + + assertNotNull(bufferResponse.getBuffer()); + assertTrue(bufferResponse.getBuffer().isRecycled()); + } finally { + releaseResource(inputGate, networkBufferPool); + } + } + + @Test + public void testReceivedBufferForReleasedChannel() throws Exception { + final int bufferSize = 1024; + + NetworkBufferPool networkBufferPool = new NetworkBufferPool(10, bufferSize, 2); + SingleInputGate inputGate = createSingleInputGate(1); + RemoteInputChannel inputChannel = createRemoteInputChannel(inputGate, null, networkBufferPool); + inputGate.assignExclusiveSegments(); + + CreditBasedPartitionRequestClientHandler handler = new CreditBasedPartitionRequestClientHandler(); + handler.addInputChannel(inputChannel); + + try { + Buffer buffer = TestBufferFactory.createBuffer(bufferSize); + BufferResponse bufferResponse = createBufferResponse( + buffer, + 0, + inputChannel.getInputChannelId(), + 1, + new NetworkBufferAllocator(handler)); + + inputGate.close(); Review comment: There should not be such tests now, thus new tests are added. The common code is also extracted into utility method. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services