0

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

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

当我滚动网格时,有时它会生成一个 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)

但是其他具有更多列和更多数据的网格(我的一个案例超过 2000 个)绝对不会导致异常。我已经检查了 NPE 发生时要从提供程序加载的最后一个数据库对象的 id(将网格页面设置为 1 以确保它是最后一个),它永远不会相同,并且对于来自其他对象的其他对象没有什么特别的网格。

我正在填充网格,主要通过实体的 propId 设置列,有些是生成的列,比如另外两列的总和。

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

提前致谢 !

4

1 回答 1

0

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

随机效应是由网格渲染延迟引起的,有时它在渲染错误行之前的行之前已经失败。

于 2018-09-14T12:03:08.087 回答