Search code examples
vaadinvaadin10vaadin-flow

Grid with Viritin ListDataProvider fail randomly


I'm developing a Vaadin Flow (10.0.5) app with several grids inside. All of those use the ListDataProvider from Viritin.

The one that cause me headache is generally composed of 200-300 rows (some cases have up to 1200 rows) and has 13 columns. All columns are resizable and sortable, and a second header row contains filters for each column, like every other grid in the app.

When I scroll through the grid, sometime it generate a NPE :

java.lang.NullPointerException
at sun.reflect.GeneratedMethodAccessor403.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.__invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.vaadin.flow.data.binder.BeanPropertySet.invokeWrapExceptions(BeanPropertySet.java:516)
at com.vaadin.flow.data.binder.BeanPropertySet.access$600(BeanPropertySet.java:48)
at com.vaadin.flow.data.binder.BeanPropertySet$NestedBeanPropertyDefinition.lambda$getGetter$3ec26976$1(BeanPropertySet.java:200)
at com.vaadin.flow.component.grid.Grid.runPropertyValueGetter(Grid.java:1137)
at com.vaadin.flow.component.grid.Grid.lambda$addColumn$cb98939f$1(Grid.java:1119)
at com.vaadin.flow.component.grid.Grid.lambda$addColumn$c3690ee2$1(Grid.java:923)
at com.vaadin.flow.data.renderer.Renderer$TemplateRendering.lambda$null$2db14883$1(Renderer.java:261)
at com.vaadin.flow.data.provider.CompositeDataGenerator.lambda$generateData$0(CompositeDataGenerator.java:47)
at java.lang.Iterable.forEach(Unknown Source)
at com.vaadin.flow.data.provider.CompositeDataGenerator.generateData(CompositeDataGenerator.java:47)
at com.vaadin.flow.data.provider.CompositeDataGenerator.lambda$generateData$0(CompositeDataGenerator.java:47)
at java.lang.Iterable.forEach(Unknown Source)
at com.vaadin.flow.data.provider.CompositeDataGenerator.generateData(CompositeDataGenerator.java:47)
at com.vaadin.flow.data.provider.DataCommunicator.generateJson(DataCommunicator.java:627)
at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
at java.util.stream.IntPipeline$4$1.accept(Unknown Source)
at java.util.stream.Streams$RangeIntSpliterator.forEachRemaining(Unknown Source)
at java.util.Spliterator$OfInt.forEachRemaining(Unknown Source)
at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.util.stream.ReferencePipeline.collect(Unknown Source)
at com.vaadin.flow.data.provider.DataCommunicator.getJsonItems(DataCommunicator.java:587)
at com.vaadin.flow.data.provider.DataCommunicator.lambda$collectChangesToSend$2(DataCommunicator.java:550)
at com.vaadin.flow.data.provider.DataCommunicator.applyIfNotEmpty(DataCommunicator.java:601)
at com.vaadin.flow.data.provider.DataCommunicator.withMissing(DataCommunicator.java:595)
at com.vaadin.flow.data.provider.DataCommunicator.collectChangesToSend(DataCommunicator.java:549)
at com.vaadin.flow.data.provider.DataCommunicator.flush(DataCommunicator.java:452)
at com.vaadin.flow.data.provider.DataCommunicator.lambda$requestFlush$2f364bb9$1(DataCommunicator.java:409)
at com.vaadin.flow.internal.StateTree.lambda$runExecutionsBeforeClientResponse$1(StateTree.java:350)
at java.util.ArrayList.forEach(Unknown Source)
at com.vaadin.flow.internal.StateTree.runExecutionsBeforeClientResponse(StateTree.java:347)
at com.vaadin.flow.server.communication.UidlWriter.encodeChanges(UidlWriter.java:334)
at com.vaadin.flow.server.communication.UidlWriter.createUidl(UidlWriter.java:179)
at com.vaadin.flow.server.communication.UidlRequestHandler.writeUidl(UidlRequestHandler.java:119)
at com.vaadin.flow.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:91)
at com.vaadin.flow.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
at com.vaadin.flow.server.VaadinService.handleRequest(VaadinService.java:1486)
at com.vaadin.flow.server.VaadinServlet.service(VaadinServlet.java:300)

But other grids with more columns and many more data (more than 2000 for one of my cases) cause absolutely no exception. I've checked the id of the last database object to be loaded from the provider when the NPE occur (set grid page to 1 to be sure it's the last), it's never the same and it has nothing special regarding the other objects from the grid.

I'm filling the grid setting the columns mostly by the propId of the entity, some are generated columns, like sum of two other columns.

Any idea of what can cause those random exceptions ?

Thanks in advance !


Solution

  • After overriding Grid and putting a logger in the runPropertyValueGetter, it appear that the NPE was caused by a null nested entity in an other nested entity which is nested in the grid main entity.

    The random effect was caused by a delay in the rendering of the Grid, sometimes it has failed before rendering the row before the faulty one.