Skip to content
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

Classloader matching for BeanDeploymentArchives #24933

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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