Delay DataBuffer release until stream is closed
This commit changes the release of data buffers from a finally block into a `doFinally()` lambda on the returned `Flux<XMLEvent>` stream. Issue: SPR-15707
This commit is contained in:
parent
b1f06fddd2
commit
9d7b8503d0
|
|
@ -106,14 +106,14 @@ public class XmlEventDecoder extends AbstractDecoder<XMLEvent> {
|
|||
try {
|
||||
InputStream is = dataBuffer.asInputStream();
|
||||
Iterator eventReader = inputFactory.createXMLEventReader(is);
|
||||
return Flux.fromIterable((Iterable<XMLEvent>) () -> eventReader);
|
||||
return Flux.fromIterable((Iterable<XMLEvent>) () -> eventReader)
|
||||
.doFinally(t -> {
|
||||
DataBufferUtils.release(dataBuffer);
|
||||
});
|
||||
}
|
||||
catch (XMLStreamException ex) {
|
||||
return Mono.error(ex);
|
||||
}
|
||||
finally {
|
||||
DataBufferUtils.release(dataBuffer);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue