Jozef Hartinger created WELD-1076:
-------------------------------------
Summary: Deal with non-serializable dependent instances of a passivation
capable bean
Key: WELD-1076
URL:
https://issues.jboss.org/browse/WELD-1076
Project: Weld
Issue Type: Task
Affects Versions: 2.0.0.Alpha1
Reporter: Jozef Hartinger
Assignee: Jozef Hartinger
Fix For: 2.0.0.Alpha2
Since
https://github.com/jboss/cdi/pull/47 it is legal for a normal-scoped component to
have a non-passivation capable dependency, e.g:
{CODE:JAVA}
@SessionScoped
public class Foo implements Serializable {
@Inject
public Foo(Bar bar) {
}
}
public class Bar {
}
{CODE}
Although the Bar instance reference is not retained by the Foo instance, the Bar instance
is still technically a dependent instance of Foo and therefore the container needs to keep
a reference to it in order to eventually destroy it properly.
We may make use of the following part of the spec:
{QUOTE}
Finally, the container is permitted to destroy any @Dependent scoped contextual instance
at any time if the instance is no
longer referenced by the application (excluding weak, soft and phantom references)."
{QUOTE}
and destroy every non-serializable dependent bean instance of a normal-scoped bean when
the creational context for the normal-scoped bean instance is serialized.
This should be safe for these cases:
* Foo no longer holds a reference to Bar, therefore we can destroy Bar
* Foo holds a reference to Bar - does not matter if we destroy Bar prematurely since
serialization of Bar is going to fail anyway
* Foo holds a reference to Bar in a transient field and is therefore either going to
"forget" the reference (therefore we can destroy it) or is able to recreate the
Bar instance itself on deserialization
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see:
http://www.atlassian.com/software/jira