You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let’s say I have a backend data-provider for a stream of strings read from a BufferedReader, e.g.
public Stream<String> fetchFromBackend(Query<String> query) {
var reader = createBufferedReader();
return reader.lines().skip(query.getOffset()).limit(query.getLimit()).onClose(reader::close);
}
In this case I want to be sure to close the reader when the stream reaches a terminal operation, so I do onClose(reader::close). Problem is, when the DataCommunicator gets that stream:
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
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>
Description of the bug
Let’s say I have a backend data-provider for a stream of strings read from a
BufferedReader
, e.g.In this case I want to be sure to close the reader when the stream reaches a terminal operation, so I do
onClose(reader::close)
. Problem is, when theDataCommunicator
gets that stream:flow/flow-data/src/main/java/com/vaadin/flow/data/provider/DataCommunicator.java
Line 1055 in b8a992a
then it is never closed. This also applies to the
DataView
API, e.g.flow/flow-data/src/main/java/com/vaadin/flow/data/provider/AbstractDataView.java
Lines 153 to 155 in b8a992a
Expected behavior
Upon calling terminal operations, the stream is then closed.
Minimal reproducible example
See code snippet in the description above.
Versions
The text was updated successfully, but these errors were encountered: