-
Bug
-
Resolution: Done
-
Major
-
2.1.2.Final, 3.0.0.Alpha17
-
None
In WildFly 8.1.0.Final, I observed that sometimes an injected instance of a custom scoped component was an old instance, belonging to a scope that had already been removed. After a long investigation, I found the root cause of this problem. It has to do with the bean instance caching that happens in client proxies for built in scoped beans (see Weld's class ClientProxyFactory). All beans with the same bean type make use of the same client proxy class, and this proxy class determines whether instances are cached or not. If, for a certain bean type, the first proxy that needs to be constructed is for a built in scoped bean, a caching proxy class is created, and that class will also be used for all future proxies, even if they refer to a bean that is custom scoped.
See "steps to reproduce" for further details.
The problem can be fixed by including a caching indicator in the name of the generated client proxy class (see pull request).