Skip to content

Commit

Permalink
Fix potential duplicate returns in getResources
Browse files Browse the repository at this point in the history
ClassLoaders make no garentee about uniqueness, but this case is simple enough to detect
  • Loading branch information
LexManos committed Mar 4, 2024
1 parent 5d5279d commit 80b4a40
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,18 @@ public SecureModuleClassLoader(String name, ClassLoader parent, Configuration co
super(name, getSingleParent(parent, parentLoaders));
this.DEBUG = shouldDebug(name);

if (parent == null && parentLoaders.size() == 1)
this.parent = parentLoaders.iterator().next();
else
this.parent = parent;
this.configuration = config;
this.useCachedSignersForUnsignedCode = useCachedSignersForUnsignedCode;
this.parents = findAllParentLayers(parentLayers);
this.allParentLoaders = !parentLoaders.isEmpty() ? parentLoaders : findAllParentLoaders(this.parents);

// If we only have one parent, then use it as the main parent so we don't duplicate resources
if (parent == null && parentLoaders.size() == 1) {
this.parent = parentLoaders.iterator().next();
this.allParentLoaders = Collections.emptyList();
} else {
this.parent = parent;
this.allParentLoaders = !parentLoaders.isEmpty() ? parentLoaders : findAllParentLoaders(this.parents);
}

// Find all modules for this config, if the reference is our special Secure reference, we can define packages with security info.
for (var module : config.modules()) {
Expand Down

0 comments on commit 80b4a40

Please sign in to comment.