[INT-4506] AbstractMessageSplitter does not close java.util.Stream payloads Created: 25/Jul/18  Updated: 02/Aug/18  Resolved: 25/Jul/18

Status: Closed
Project: Spring Integration
Component/s: Core
Affects Version/s: 5.0.6
Fix Version/s: 5.0.7

Type: Bug Priority: Major
Reporter: Timur Strekalov Assignee: Gary Russell
Resolution: Complete Votes: 0
Labels: PullRequest
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Pull Request URL: https://github.com/spring-projects/spring-integration/pull/2518

 Description   

From what I can tell, streams are handled by converting them to iterators, and then closing the iterator if it's Closeable.

However, by that point the information about the underlying stream is lost, and the returned iterator isn't closeable, so the stream is never closed.

This effectively means there's no support for e.g. streaming results from a database where the underlying connection is released when the stream is closed.



 Comments   
Comment by Artem Bilan [ 25/Jul/18 ]

Well, since we have this public interface BaseStream<T, S extends BaseStream<T, S>> extends AutoCloseable in Java it looks like we always have to wrap iterator = stream.iterator(); into the CloseableIterator and delegate close() to the Stream we got.

Comment by Gary Russell [ 25/Jul/18 ]

That's effectively what I did, except in a more general way.

Comment by Timur Strekalov [ 25/Jul/18 ]

BTW, Closeable extends AutoCloseable, so you shouldn't have to check for both if handling them the same way

Comment by Gary Russell [ 25/Jul/18 ]

Hmmm - thanks - I'll go back and look; the test failed until I added the AutoCloseable code.

Comment by Artem Bilan [ 25/Jul/18 ]

Thank you for the report and feedback, Timur Strekalov!

As you see we have a Pull Request on the matter already.
Please, consider to continue to comment there: https://github.com/spring-projects/spring-integration/pull/2518

Generated at Wed Jul 15 09:52:05 UTC 2020 using Jira 8.5.4#805004-sha1:0444eab799707f9ad7b248d69f858774aadfd250.