Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Grid component: RpcDataProviderExtension not serializable when not attached
Java Version: 1.8
I have a screen that has a list of Grid components populated with data. It then adds one of those grids at a time to the UI based on user selections. The other grids are referenced by a collection, but aren't part of the component tree.
This application is setup to serialize the user's session after each request to support failover.
When one of the Grids which isn't attached to the UI component tree has rows in it and then I attempt to serialize the user's session I receive a java.io.NotSerializableException: com.vaadin.server.communication.data.RpcDataProviderExtension$3.
From my debugging it appears that when you call addRow on the Grid it will eventually call down to com.vaadin.data.RpcDataProviderExtension.insertRowData. At this point it adds a new Runnable (not serializable) anonymous class instance to the rowChanges field on the RpcDataProviderExtension class.
Normally when the component is connected to the UI, beforeClientResponse() method will be called which then clears the rowChanges field before any serialization is attempted.
In the case of the Grid not being attached, these rowChange instances just accumulate and then serialization is not possible.
From what I can tell, I see no reason why a Runnable interface needs to be used. It seems this could be re-written as some other interface or class that is serializable.
I'm able to work around this by not adding the rows to the grid until they're attached, but this doesn't seem like it should be required.
Can someone confirm this is a bug in the framework?