带有 Viritin ListDataProvider 的网格随机失败

Grid with Viritin ListDataProvider fail randomly

我正在开发一个内部有多个网格的 Vaadin Flow (10.0.5) 应用程序。所有这些都使用 Viritin 的 ListDataProvider。

让我头疼的一般是200-300行(有的情况下高达1200行),13列。所有列都可以调整大小和排序,第二个 header 行包含每列的过滤器,就像应用程序中的所有其他网格一样。

当我滚动浏览网格时,有时它会生成一个 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.access0(BeanPropertySet.java:48)
at com.vaadin.flow.data.binder.BeanPropertySet$NestedBeanPropertyDefinition.lambda$getGetterec26976(BeanPropertySet.java:200)
at com.vaadin.flow.component.grid.Grid.runPropertyValueGetter(Grid.java:1137)
at com.vaadin.flow.component.grid.Grid.lambda$addColumn$cb98939f(Grid.java:1119)
at com.vaadin.flow.component.grid.Grid.lambda$addColumn$c3690ee2(Grid.java:923)
at com.vaadin.flow.data.renderer.Renderer$TemplateRendering.lambda$nulldb14883(Renderer.java:261)
at com.vaadin.flow.data.provider.CompositeDataGenerator.lambda$generateData[=10=](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[=10=](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.accept(Unknown Source)
at java.util.stream.ReferencePipeline.accept(Unknown Source)
at java.util.stream.IntPipeline.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(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$requestFlushf364bb9(DataCommunicator.java:409)
at com.vaadin.flow.internal.StateTree.lambda$runExecutionsBeforeClientResponse(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)

但是其他具有更多列和更多数据的网格(我的一个案例超过 2000 个)绝对不会例外。 我已经检查了 NPE 发生时要从提供商加载的最后一个数据库的 ID object(将网格页面设置为 1 以确保它是最后一个),它从来都不相同,并且没有什么特别之处网格中的其他 object 个。

我主要通过实体的 propId 来填充设置列的网格,有些是生成的列,例如其他两列的总和。

知道什么会导致这些随机异常吗?

提前致谢!

覆盖 Grid 并将记录器放入 runPropertyValueGetter 后,NPE 似乎是由嵌套在另一个嵌套实体中的 null 嵌套实体引起的网格主要实体。

随机效果是由于网格渲染延迟造成的,有时在错误行之前渲染之前就失败了。