提交 81f95efd 编写于 作者: R Rossen Stoyanchev

Call onDispose before first read

The cancellation callback in asynchronousReadFileChannel must be called
before the first read I/O or otherwise if cancellation signals happens
immediately the onDispose callback may be missed.

The DefaultBufferFactory workaround however remains in place until an
expected additional fix arrives with Reactor Core 3.2.9.

See gh-22107
上级 9a1bba5b
...@@ -144,10 +144,10 @@ public abstract class DataBufferUtils { ...@@ -144,10 +144,10 @@ public abstract class DataBufferUtils {
channel -> Flux.create(sink -> { channel -> Flux.create(sink -> {
ReadCompletionHandler handler = ReadCompletionHandler handler =
new ReadCompletionHandler(channel, sink, position, bufferFactoryToUse, bufferSize); new ReadCompletionHandler(channel, sink, position, bufferFactoryToUse, bufferSize);
sink.onDispose(handler::dispose);
DataBuffer dataBuffer = bufferFactoryToUse.allocateBuffer(bufferSize); DataBuffer dataBuffer = bufferFactoryToUse.allocateBuffer(bufferSize);
ByteBuffer byteBuffer = dataBuffer.asByteBuffer(0, bufferSize); ByteBuffer byteBuffer = dataBuffer.asByteBuffer(0, bufferSize);
channel.read(byteBuffer, position, dataBuffer, handler); channel.read(byteBuffer, position, dataBuffer, handler);
sink.onDispose(handler::dispose);
}), }),
channel -> { channel -> {
// Do not close channel from here, rather wait for the current read callback // Do not close channel from here, rather wait for the current read callback
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册