IndexOutOfBounds for DataProvider
See original GitHub issueCreated a DataProvider.fromCallbacks object. First page of paging works correctly, second load of data,however causes an indexoutofbounds error: query.getOffset(): 0 query.getLimit(): 50 query.getOffset(): 50 query.getLimit(): 50 java.lang.IndexOutOfBoundsException: Index: 50, Size: 50
java.lang.IndexOutOfBoundsException: Index: 50, Size: 50 at java.util.ArrayList.rangeCheck(ArrayList.java:657) ~[na:1.8.0_212] at java.util.ArrayList.get(ArrayList.java:433) ~[na:1.8.0_212] at com.vaadin.flow.data.provider.DataCommunicator.lambda$getJsonItems$3(DataCommunicator.java:611) ~[flow-data-1.4.6.jar!/:1.4.6]
- Minimal reproducible example This is about as stripped down as I can make it quickly while keeping this verbose for you…
DataProvider<License,Void> licenseDataProvider = DataProvider.fromCallbacks(
new CallbackDataProvider.FetchCallback<License, Void>() {
@Override
Stream<License> fetch(Query<License, Void> query) {
println "query.getOffset(): "+query.getOffset()
println "query.getLimit(): "+ query.getLimit()
Stream<License> licenseStream = licenseRepository.findByZenGroupId(user.getZenGroupId()).subList(query.getOffset(),query.getLimit()).stream()
//licensePage = licensePagingRepository.findAllByZenGroupId(user.getZenGroupId(), new PageRequest(query.getOffset(), limit))
return licenseStream
}
},new CallbackDataProvider.CountCallback<License, Void>() {
@Override
int count(Query<License, Void> query) {
//println "totalElements:"+licensePagingRepository.findAllByZenGroupId(user.getZenGroupId(), new PageRequest(query.getOffset(), query.getLimit())).getNumber()
//println "numberOfElements:"+licensePagingRepository.countByZenGroupId(user.getZenGroupId(), new PageRequest(query.getOffset(), query.getLimit()))
return licenseRepository.countByZenGroupId(user.getZenGroupId())
}
})
- Expected behavior DataProvider lazy loading population to a grid.
- Actual behavior Crash upon scroll.
- Versions:
- Vaadin / Flow version 13.0.10
- Java version Java: 1.8.212 zulu Spring: Spring boot 2.1.6.RELEASE
- OS version: Server: Ubuntu
- Browser version (if applicable) –N/A
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
IndexOutOfBoundsException in DataProvider query using ...
As I wrote in the question I am aware of the meaning of the exception. The DataProvider is used in the scope of...
Read more >ArrayIndexOutOfBoundsException with @DataProvider in ...
I'm using a data provider for one of tests but am receiving an ArrayIndexOutOfBoundsException when I run the test. ENVIRONMENT TestNG 5.5 --...
Read more >Grid & Grid Pro IndexOutOfBoundsException - Vaadin
What seems to be the case is that the Spring-data PageRequest.of does not work on the same basis as Vaadin DataProvider.fromCallbacks. The definition...
Read more >How to fix java.lang.indexoutofboundsexception : invalid array ...
The error is pretty explicit: indexoutofboundsexception : invalid array range: 1 to 1. So somewhere in that code you are using an array...
Read more >com.businessobjects.rebean.wi Interface DataProviders
The DataProviders interface defines a collection of data providers. ... ArrayIndexOutOfBoundsException - if index is out of range ( index < 0 ||...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
On a completely different note, I’d also like to address this comment:
In order to determine that the problem was in the example code and not in Vaadin itself, I had to make assumptions about the implementation of the missing classes and how the data provider was used. This was a relatively straightforward case but as an example, the symptoms would have been different if I’d used the data provider with a
Select
component instead ofGrid
.There have also been cases where we have made wrong assumptions without noticing and then ended up only implementing a partial fix or fixing a completely different related issue instead of fixing the issue faced by the reporter.
We are receiving hundreds of reports through open source issue trackers every week. We want to dedicate our time to fixing actual issues or implementing new features rather than filling in blanks in reported issues or making changes that are not helping the reporter. By providing a fully functional example that can be run as-is, you are significantly increasing the chances that you will receive help quickly and efficiently.
In this case, a functionally equivalent self-contained example could have been implemented like this:
@jhult I found a solution…we had moved on shortly afterwards.