Github user pnowojski commented on a diff in the pull request:

    https://github.com/apache/flink/pull/5581#discussion_r170921245
  
    --- Diff: 
flink-runtime/src/test/java/org/apache/flink/runtime/io/network/partition/SpillableSubpartitionTest.java
 ---
    @@ -332,56 +290,41 @@ public void 
testConsumeSpillablePartitionSpilledDuringConsume() throws Exception
                // only updated when getting/spilling the buffers but without 
the nextBuffer (kept in memory)
                assertEquals(BUFFER_DATA_SIZE * 3 + 4, 
partition.getTotalNumberOfBytes());
     
    +           // wait for successfully spilling all buffers (before that we 
may not access any spilled buffer and cannot rely on isMoreAvailable!)
                listener.awaitNotifications(2, 30_000);
                assertEquals(2, listener.getNumNotifications());
     
    +           // after consuming and releasing the next buffer, the 
bufferConsumer may be freed,
    +           // depending on the timing of the last write operation
    +           // -> retain once so that we can check below
    +           Buffer buffer = bufferConsumer.build();
    +           buffer.retainBuffer();
    +
                assertFalse(reader.nextBufferIsEvent()); // second buffer 
(retained in SpillableSubpartition#nextBuffer)
    -           read = reader.getNextBuffer();
    -           assertNotNull(read);
    -           assertTrue(read.buffer().isBuffer());
    +           assertNextBuffer(reader, BUFFER_DATA_SIZE, true, 1, true, 
false);
                assertEquals(BUFFER_DATA_SIZE * 4 + 4, 
partition.getTotalNumberOfBytes()); // finally integrates the nextBuffer 
statistics
                assertEquals(1, partition.getBuffersInBacklog());
    -           assertEquals(partition.getBuffersInBacklog(), 
read.buffersInBacklog());
    -           read.buffer().recycleBuffer();
    -           // now the bufferConsumer may be freed, depending on the timing 
of the write operation
    -           // -> let's do this check at the end of the test (to save some 
time)
    -           assertTrue(read.nextBufferIsEvent());
    +
    +           bufferConsumer.close(); // recycle the retained buffer from 
above (should be the last reference!)
     
                assertTrue(reader.nextBufferIsEvent()); // the event (spilled)
    -           read = reader.getNextBuffer();
    -           assertNotNull(read);
    -           assertFalse(read.buffer().isBuffer());
    +           assertNextEvent(reader, BUFFER_DATA_SIZE, null, true, 1, false, 
true);
    --- End diff --
    
    ditto


---

Reply via email to