-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Close streams fetched from data-providers #18552
Conversation
The change looks good to me 👍
|
Updated the JavaDoc with the recommendation and code example.
Closing streams also for hierarchical communicators and mapper now. I'm just having a hard time understanding how unit tests work for the hierarchical API, I added one covering |
@heruan great work! Something like @Test
public void fetchHierarchyItems_streamIsClosed() {
AtomicBoolean streamIsClosed = new AtomicBoolean();
mapper = new HierarchyMapper<>(new TreeDataProvider<>(data) {
@Override
public Stream<Node> fetchChildren(HierarchicalQuery<Node, SerializablePredicate<Node>> query) {
return super.fetchChildren(query)
.onClose(() -> streamIsClosed.set(true));
}
});
Node rootNode = testData.get(0);
mapper.expand(rootNode);
mapper.fetchHierarchyItems(rootNode, Range.between(0, 10)).count();
Assert.assertTrue(streamIsClosed.get());
} |
Oh there it is, thanks! I added two tests to |
Quality Gate passedKudos, no new issues were introduced! 0 New issues |
Fixes DataCommunicator API by handling the streams fetched from data-providers inside try-with-resources blocks. Unclosed streams might still leak from the DataView API, that should be fixed in each component using that API. Fixes #18551
Fixes DataCommunicator API by handling the streams fetched from data-providers inside try-with-resources blocks. Unclosed streams might still leak from the DataView API, that should be fixed in each component using that API. Fixes #18551 Co-authored-by: Giovanni Lovato <giovanni@vaadin.com>
This is an attempt to fix #18551 for the
DataCommunicator
API by handling the streams fetched from data-providers inside try-with-resources blocks.Unclosed streams might still leak from the
DataView
API, that should be fixed in each component using that API.