Github user NicoK commented on a diff in the pull request: https://github.com/apache/flink/pull/4509#discussion_r152962580 --- Diff: flink-runtime/src/test/java/org/apache/flink/runtime/io/network/partition/consumer/RemoteInputChannelTest.java --- @@ -330,64 +332,120 @@ public void testRequestAndReturnFloatingBuffer() throws Exception { // Prepare the exclusive and floating buffers to verify recycle logic later Buffer exclusiveBuffer = inputChannel.requestBuffer(); assertNotNull(exclusiveBuffer); - Buffer floatingBuffer1 = bufferPool.requestBuffer(); - assertNotNull(floatingBuffer1); - Buffer floatingBuffer2 = bufferPool.requestBuffer(); - assertNotNull(floatingBuffer2); + + final int numRecycleFloatingBuffers = 4; + final ArrayDeque<Buffer> floatingBufferQueue = new ArrayDeque<>(numRecycleFloatingBuffers); + for (int i = 0; i < numRecycleFloatingBuffers; i++) { + Buffer floatingBuffer = bufferPool.requestBuffer(); + assertNotNull(floatingBuffer); + floatingBufferQueue.add(floatingBuffer); + } --- End diff -- if you add `verify(bufferPool, times(4)).requestBuffer();` here, the difference to the 13 below becomes a bit more clear (because the requests are absolute values while as differences would be clear from the start, i.e. that we request 9 additional buffers - unfortunately, Mockito does not provide this as far as I know - but that's not a big deal as soon as everything is clear)
---