Should members in Views be Serializable or transient?

Note that what I found is caused by Vaadin. I would like to get Jmix’ perspective on this as the View class implements the Vaadin interfaces.

I installed sonar and started cleaning up my codebase.

I receive errors stating that fields in my Views should be either Serializable or transient. I investigated and found that Vaadin event-related interfaces, such as BeforeEnterObserver, all implement Serializable.

Technically, Sonar is right, Vaadin could serialize the views and their state.

I don’t think I ever saw a single Jmix sample doing this. So, what is the rationale here? Do you just suppress the error -perhaps because in jmix we never serialize since we have no session replication- ?

image

Hi Tom,

Vaadin itself never serializes anything, but its UI components are serializable to support standard Java serialization by a web server. Jmix components don’t follow this practice because in real-world Jmix applications the UI state is so large that the sessions cannot be replicated (using serialization) without killing the server performance.

Yes I would recommend just suppressing this warning.

Regards,
Konstantin

1 Like