Exception in DataCommunicator

Sometimes I found in my logfile the following exception. Does anyone have an idea?

java.lang.IndexOutOfBoundsException: toIndex = 150
at java.base/java.util.AbstractList.subListRangeCheck(AbstractList.java:507)
at java.base/java.util.AbstractList.subList(AbstractList.java:497)
at com.vaadin.flow.data.provider.DataCommunicator.collectKeysToFlush(DataCommunicator.java:1379)
at com.vaadin.flow.data.provider.DataCommunicator.flush(DataCommunicator.java:1168)
at com.vaadin.flow.data.provider.DataCommunicator.lambda$requestFlush$7258256f$1(DataCommunicator.java:1103)
at com.vaadin.flow.internal.StateTree.lambda$runExecutionsBeforeClientResponse$2(StateTree.java:392)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
at

Are you using this for infinite scroll in grids or something else? If you are using this to enable infinite scroll you may want to check that your count function equals the same number of items that you are using to populate your grid.

I initialize my grid with a page size of 150. My grid uses the full width/height of the screen. What do you mean with infinite scroll and what do you mean with count function?

Currently I call

           dataProvider = DataProvider.ofCollection(itemList);
           grid.setItems(dataProvider);

and afterwards I change my entries like the folliwing:

    itemList.clear();
    itemList.addAll(items);
    dataProvider.refreshAll();

Is this the correct way to handle it?

You should not need to set a page size at all

I also have this issues:

java.lang.IndexOutOfBoundsException: Index 1 out of bounds for length 1
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) ~[na:na]
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) ~[na:na]
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) ~[na:na]
at java.base/java.util.Objects.checkIndex(Objects.java:359) ~[na:na]
at java.base/java.util.ArrayList.get(ArrayList.java:427) ~[na:na]
at com.vaadin.flow.data.provider.DataCommunicator.lambda$getJsonItems$7(DataCommunicator.java:1391) ~[flow-data-23.2.2.jar:23.2.2]

Probably this is because I now use MultiSelectComboBox to add multiple values to one item in a table.

But can this cause the issue?

Maybe?

Okay, but I do not understand the reason why :wink:

Found the reason

what was it?

In a querie a select was returning a higher count than it should have

SELECT COUNT(DISTINCT s.id)

adding the distinct fixed it.

What was happenings was that because of a join in the db the count for the paging of the table returned 2

while in the data base and table only one item existed.

Vaadin then complained that is was asked to “draw” 2 items in the table, but it did receive only 1.

But how can this happen for my application? I select all data and afterwards I add all items to the list?