Skip to content

Commit

Permalink
Don't combine resources from the two classloaders in KnotClassLoader.…
Browse files Browse the repository at this point in the history
…getResources (#747)
  • Loading branch information
modmuss50 authored Dec 20, 2022
1 parent 7fde9dc commit 97b8445
Showing 1 changed file with 7 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,46 +98,13 @@ public InputStream getResourceAsStream(String name) {
public Enumeration<URL> getResources(String name) throws IOException {
Objects.requireNonNull(name);

Enumeration<URL> first = urlLoader.getResources(name);
Enumeration<URL> second = originalLoader.getResources(name);
return new Enumeration<URL>() {
Enumeration<URL> current = first;

@Override
public boolean hasMoreElements() {
if (current == null) {
return false;
}

if (current.hasMoreElements()) {
return true;
}

if (current == first && second.hasMoreElements()) {
return true;
}

return false;
}

@Override
public URL nextElement() {
if (current == null) {
return null;
}

if (!current.hasMoreElements()) {
if (current == first) {
current = second;
} else {
current = null;
return null;
}
}

return current.nextElement();
}
};
final Enumeration<URL> resources = urlLoader.getResources(name);

if (!resources.hasMoreElements()) {
return originalLoader.getResources(name);
}

return resources;
}

@Override
Expand Down

0 comments on commit 97b8445

Please sign in to comment.