-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: support serialization of Vaadin scoped beans #20394
fix: support serialization of Vaadin scoped beans #20394
Conversation
Makes sure that VaadinSession and UI thread locals are available during both serialization and deserialization, to allow other libraries to perform inspection and injection of Vaadin scoped beans. Also refactors VaadinRouteScope to be independent from VaadinService when fetching RouteScopeOwner annotation for the bean, and replaces VaadinSession.unlock() calls with direct access to the lock instance to prevent unwanted push during bean lookup. Fixes #19967 Part of vaadin/kubernetes-kit#140
Vaadin scoped beans requires VaadinSession and UI thread locals to be set in order to lookup beans. This change tracks Vaadin scoped beans during serialization and makes sure that required thread locals are set during deserialization. The serialVersionUID added to TransientDescriptor should keep it compatible with older version, preventing deserialization of previous data to fail. Fixes #140 Requires vaadin/flow#20394
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to double check CDI and Quarkus add-ons for the similar changes?
} | ||
} | ||
|
||
@Serial |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add @Serial
to the same methods in VaadinSession
class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, makes sense, even though it is not required
@@ -369,10 +355,52 @@ private NavigationListener getNavigationListener() { | |||
|
|||
} | |||
|
|||
private record ObjectWithOwner(Object object, RouteScopeOwner owner) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need implements Serializable
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. The object is not stored anywhere. It is only used as a carrier of information for other logics.
Currently, custom logic for handling scoped beans during deserialization is implemented only in Kubernetes Kit and only for Spring. |
Quality Gate passedIssues Measures |
Makes sure that VaadinSession and UI thread locals are available during both serialization and deserialization, to allow other libraries to perform inspection and injection of Vaadin scoped beans. Also refactors VaadinRouteScope to be independent from VaadinService when fetching RouteScopeOwner annotation for the bean, and replaces VaadinSession.unlock() calls with direct access to the lock instance to prevent unwanted push during bean lookup. Fixes #19967 Part of vaadin/kubernetes-kit#140 Co-authored-by: Mikhail Shabarov <61410877+mshabarov@users.noreply.github.com>
Hi @mcollovati and @mshabarov, when i performed cherry-pick to this commit to 24.4, i have encountered the following issue. Can you take a look and pick it manually? |
Makes sure that VaadinSession and UI thread locals are available during both serialization and deserialization, to allow other libraries to perform inspection and injection of Vaadin scoped beans. Also refactors VaadinRouteScope to be independent from VaadinService when fetching RouteScopeOwner annotation for the bean, and replaces VaadinSession.unlock() calls with direct access to the lock instance to prevent unwanted push during bean lookup. Fixes #19967 Part of vaadin/kubernetes-kit#140 Co-authored-by: Marco Collovati <marco@vaadin.com> Co-authored-by: Mikhail Shabarov <61410877+mshabarov@users.noreply.github.com>
Makes sure that VaadinSession and UI thread locals are available during both serialization and deserialization, to allow other libraries to perform inspection and injection of Vaadin scoped beans. Also refactors VaadinRouteScope to be independent from VaadinService when fetching RouteScopeOwner annotation for the bean, and replaces VaadinSession.unlock() calls with direct access to the lock instance to prevent unwanted push during bean lookup. Fixes #19967 Part of vaadin/kubernetes-kit#140 Co-authored-by: Mikhail Shabarov <61410877+mshabarov@users.noreply.github.com>
Makes sure that VaadinSession and UI thread locals are available during both serialization and deserialization, to allow other libraries to perform inspection and injection of Vaadin scoped beans. Also refactors VaadinRouteScope to be independent from VaadinService when fetching RouteScopeOwner annotation for the bean, and replaces VaadinSession.unlock() calls with direct access to the lock instance to prevent unwanted push during bean lookup. Fixes #19967 Part of vaadin/kubernetes-kit#140 Co-authored-by: Mikhail Shabarov <61410877+mshabarov@users.noreply.github.com>
Description
Makes sure that VaadinSession and UI thread locals are available during both serialization and deserialization, to allow other libraries to perform inspection and injection of Vaadin scoped beans.
Also refactors VaadinRouteScope to be independent from VaadinService when fetching RouteScopeOwner annotation for the bean, and replaces VaadinSession.unlock() calls with direct access to the lock instance to prevent unwanted push during bean lookup.
Fixes #19967
Part of vaadin/kubernetes-kit#140
Type of change
Checklist
Additional for
Feature
type of change