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
This commit is contained in:
parent
9a1bba5b67
commit
81f95efdbb
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue