The same beanClass may be within several BeanDeploymentArchives. In it's current form, it returns the first matching BDA by checking if the beanClass is can be found within that BDA. If the incorrect BDA is returned, for example in:
The change here tightens the condition for returning the correct BDA, by matching it's module class loader to the incoming beanClass to ensure no classcastexception is thrown when the generated objected is cast back to beanClass.
The same beanClass may be within several BeanDeploymentArchives. In it's current form, it returns the first matching BDA by checking if the beanClass is can be found within that BDA. If the incorrect BDA is returned, for example in:
https://github.com/eclipse-ee4j/glassfish/blob/5d59bb6a60301341125438bebe36aac35c0337ae/appserver/web/weld-integration/src/main/java/org/glassfish/weld/services/CDIServiceImpl.java#L418
then the classloader of the instantiated object in
createManagedObject
will belong (based on https://github.com/weld/core/blob/aab0ff03a84ea5718a515e9193a64b190e8f8479/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java#L1176) to the initiating class loader which first created the managed bean. This results in aclasscastexception
if subsequent requests for the same beanclass is coming from a different classloader (i.e. the classloader of themanagedClass
is disregarded).The change here tightens the condition for returning the correct BDA, by matching it's module class loader to the incoming beanClass to ensure no
classcastexception
is thrown when the generated objected is cast back to beanClass.