-
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
IllegalArgumentException: length must not be negative in DataCommunicator with undefined size #9988
Comments
Just first noting that you don't need to create an |
For this example I would not need the
I will use this API from now on, did not notice it until now. |
My assumption is that it does not matter, just wanted to mention it anyway. |
Reproducible example in vaadin/vaadin-grid#2128 |
Adds a regression test to verify the case when the items are bound to Grid lazily with unknown items count and the filter is being applied to items in the middle of scrolling. Related-to: vaadin/flow#9988
Adds a regression test to verify the case when the items are bound to Grid lazily with unknown items count and the filter is being applied to items in the middle of scrolling. Related-to: vaadin/flow#9988
Adds a regression test to verify the case when the items are bound to Grid lazily with unknown items count and the filter is being applied to items in the middle of scrolling. Related-to: vaadin/flow#9988
#647) Adds a regression test to verify the case when the items are bound to Grid lazily with unknown items count and the filter is being applied to items in the middle of scrolling. Related-to: vaadin/flow#9988
Description of the bug / feature
I have a
Grid
with aDataCommunicator
with unknown size (setDefinedSize(false)
).I am using a
TextField
to search for (i.e. filter) the items.When I scroll down until a new "block" of data is fetched, and I insert a filter string, which limits the result to a few items only, I am getting a
IllegalArgumentException: length must not be negative
Minimal reproducible example
TextField
for the searchTerm:TextField
s value as a filter. Example:Grid
with thisDataProvider
and callgrid.getDataCommunicator().setDefinedSize(false)
Expected behavior
The
Grid
should show the filtered itemsActual behavior
A
java.lang.IllegalArgumentException: length must not be negative
is thrown insteadAdditional information:
The problem seems to be, that the previous fetch loaded items with an offset, which is larger then the size of the filtered list.
For example:
items 50 to 200 are loaded. After applying the filter there are only 2 items left.
Inside
DataCommunicator#flush
therequestedRange
therefore goes from -150 to 50 and theassumedSize
is later calculated based on thatrequestedRange
(Line 1103). The calculatedassumedSize
is then negative (-148 in this case) and results in this error.I think, that instead of using
requestedRange
,effectiveRequested
should be used, which is limited to 0 toassumedSize
Versions:
The text was updated successfully, but these errors were encountered: