diff --git a/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java b/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java index 69ebec0061..5e12bed9e6 100644 --- a/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java +++ b/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java @@ -113,7 +113,7 @@ public abstract class DataBufferUtils { ByteBuffer byteBuffer = ByteBuffer.allocate(bufferSize); return Flux.create(emitter -> { - emitter.onDispose(() -> closeChannel(channel)); + emitter.setCancellation(() -> closeChannel(channel)); AsynchronousFileChannelCompletionHandler completionHandler = new AsynchronousFileChannelCompletionHandler(emitter, position, dataBufferFactory, byteBuffer);