Upload component holds reference to UI element and cause serialization exception when tomcat reloaded during development mode
See original GitHub issueDescription of the bug
This is 100% reproducible and debugable
If you use Upload component and lets say use a non-serializable reference like (crudrepository ) in ComponentEventListener<SucceededEvent>
, when you make change and live-reload triggers, the tomcat tries persist the session.
During serialization process, VaddinSession
gets serialized with reference to ComponentEventListener
which has a reference to its UI/Route component as well as this non-serializable frield (CrudRepositroy) which causes java.io.NotSerializableException
My Route definition looks like below
Expected behavior
Application show reload without and exception log
Minimal reproducible example
- Include a Upload component in a Route and also add SucceededEvent Listener
- Use Springs Data Jdbc Crud repository (or maybe any non-serialzable reference)
- Navigate the this route
- Make change and trigger auto-reload
- You will see long stack trace of exception about serialization on some Jdbc reference
Versions
Vaadin: 23.3.0.alpha1 Flow: 23.3.0.alpha1 Java: Oracle Corporation 17.0.1 OS: amd64 Windows 10 10.0 Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 Live reload: Java active (Spring Boot Devtools): Front end unavailable
Issue Analytics
- State:
- Created a year ago
- Comments:6 (1 by maintainers)
Top GitHub Comments
Most likely this is because the UIs are left out of session serialization by default in development mode but the stream resources are not. For session serialization to work, all UIs and stream resources need to be serializable. However, to fix this issue, we should probably exclude stream resources also from serialization in dev mode, when the flag is not turned on
This ticket/PR has been released with Vaadin 24.0.0.alpha6 and is also targeting the upcoming stable 24.0.0 version.