Skip to content

Commit

Permalink
Fix #5511: don't anymore rely on CodeSource#getLocation(), instead
Browse files Browse the repository at this point in the history
obtain the URL of the resource itself via its own class loader
  • Loading branch information
BalusC committed Oct 19, 2024
1 parent 2ae9565 commit c5319f0
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.sun.faces.config.manager.tasks;

import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
Expand Down Expand Up @@ -75,8 +76,14 @@ private void initializeIvars(Set<Class<?>> annotatedSet) {
String sourceURIString = sourceURI.toString();
if (annotatedSet != null) {
for (Class<?> clazz : annotatedSet) {
if (sourceURIString.contains(clazz.getProtectionDomain().getCodeSource().getLocation().toString())) {
toRemove.add(clazz);
URL resource = clazz.getClassLoader().getResource(clazz.getName().replace(".", "/") + ".class");

if (resource != null) {
String location = resource.toString().split("(?<=\\.jar)[!/].*", 2)[0];

if (sourceURIString.startsWith(location)) {
toRemove.add(clazz);
}
}
}
annotatedSet.removeAll(toRemove);
Expand Down

0 comments on commit c5319f0

Please sign in to comment.