Browse Source

Handle early exception from AsynchronousFileChannel#write

Closes gh-36184
6.2.x
rstoyanchev 1 week ago
parent
commit
c49d5dc860
  1. 8
      spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java

8
spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java

@ -1205,7 +1205,13 @@ public abstract class DataBufferUtils {
long pos = this.position.get(); long pos = this.position.get();
Attachment attachment = new Attachment(byteBuffer, dataBuffer, iterator); Attachment attachment = new Attachment(byteBuffer, dataBuffer, iterator);
this.writing.set(true); this.writing.set(true);
this.channel.write(byteBuffer, pos, attachment, this); try {
this.channel.write(byteBuffer, pos, attachment, this);
}
catch (RuntimeException ex) {
// If the exception escapes, route it to the failure handler
failed(ex, attachment);
}
} }
} }

Loading…
Cancel
Save