akalash commented on a change in pull request #15885:
URL: https://github.com/apache/flink/pull/15885#discussion_r642543767
##########
File path:
flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/io/recovery/DemultiplexingRecordDeserializerTest.java
##########
@@ -190,10 +196,12 @@ public void testWatermarks() throws IOException {
deserializer.getVirtualChannelSelectors().iterator();
iterator.hasNext(); ) {
SubtaskConnectionDescriptor selector = iterator.next();
- final BufferBuilder bufferBuilder = createBufferBuilder(128);
+ MemorySegment memorySegment = allocateUnpooledSegment(128);
+ final BufferBuilder bufferBuilder =
createBufferBuilder(memorySegment);
final long ts =
42L + selector.getInputSubtaskIndex() +
selector.getOutputSubtaskIndex();
Buffer buffer = write(bufferBuilder, new Watermark(ts));
+ bufferBuilder.recycle();
Review comment:
Unfortunately, it is not possible to implement `AutoCloseable` as the
first commit because `BufferBuilder#recycle` works correctly only after my
changes. I mean this code:
```
try(BufferBuilder bb = requestBufferBuilder) {
return bb.createBufferConsumer();
}
```
is wrong because we return an already recycled buffer. But after my changes,
it works fine.
Of course, I can move this commit to the first place for easing reviewing
but this commit will be incorrect without the next ones.
P.S. I wrapped a couple more places with try-with-resources.
--
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:
[email protected]