Skip to content

Commit

Permalink
Merge pull request #24933 from lisa-lthorrold/bda_search_fix
Browse files Browse the repository at this point in the history
Classloader matching for BeanDeploymentArchives
  • Loading branch information
dmatej committed Apr 23, 2024
2 parents d006d77 + e87e5e1 commit f9ec5d4
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,9 @@ public List<BeanDeploymentArchive> getBeanDeploymentArchives() {
* @param beanClass The beanClass to get the BeanDeploymentArchive for.
*
* @return If the beanClass is in the archive represented by the BeanDeploymentArchive then return that BeanDeploymentArchive.
* Otherwise if the class loader of the beanClass matches the module class loader of any of the root BeanDeploymentArchives
* then return that root BeanDeploymentArchive.
* If the class is represented by more than one, than perform matching by classloader of the bean class
* to return the appropriate one. Otherwise if the class loader of the beanClass matches the module class
* loader of any of the root BeanDeploymentArchives then return that root BeanDeploymentArchive.
* Otherwise return null.
*/
@Override
Expand All @@ -331,16 +332,17 @@ public BeanDeploymentArchive getBeanDeploymentArchive(Class<?> beanClass) {
return null;
}

ClassLoader classLoader = beanClass.getClassLoader();

for (BeanDeploymentArchive beanDeploymentArchive : beanDeploymentArchives) {
BeanDeploymentArchiveImpl beanDeploymentArchiveImpl = (BeanDeploymentArchiveImpl) beanDeploymentArchive;
if (beanDeploymentArchiveImpl.getKnownClasses().contains(beanClass.getName())) {
if (beanDeploymentArchiveImpl.getKnownClasses().contains(beanClass.getName()) &&
beanDeploymentArchiveImpl.getModuleClassLoaderForBDA().equals(classLoader)) {
return beanDeploymentArchive;
}
}

// Find a root BeanDeploymentArchive
ClassLoader classLoader = beanClass.getClassLoader();

RootBeanDeploymentArchive rootBda = findRootBda(classLoader, ejbRootBdas);
if (rootBda == null) {
rootBda = findRootBda(classLoader, warRootBdas);
Expand Down

0 comments on commit f9ec5d4

Please sign in to comment.