DataBufferUtils does not release DataBuffer on error cases [SPR-16782] #21322
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: backported
An issue that has been backported to maintenance branches
type: enhancement
A general enhancement
Milestone
Brian Clozel opened SPR-16782 and commented
DataBufferUtils
can writeDataBuffer
streams to file channels; the current API does leave full control to the developer and the javadoc is pretty clear on the fact that developers are in charge of releasingDataBuffer
instances.Now let's take an example; we'd like to fetch a large file using the
WebClient
and pipe it into a file on disk. An initial approach could be:As explained in the comments, if an
IOException
happens the currentDataBuffer
is not released, neither are the ones that might be instantiated already and about to be published to the pipeline.I think we should document this or assist developers here, as there is no obvious workaround here.
DataBufferUtils
is an utils class, so we need to make sure to strike the right balance between doing the right thing automatically and providing flexibility.Issue Links:
Referenced from: commits 1a0522b, 952315c
Backported to: 5.0.10
4 votes, 4 watchers
The text was updated successfully, but these errors were encountered: