mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2026-01-06 04:26:57 +00:00
MINOR: fix get resources (#16912)
* fix: get resources use set to dedupe jar list when retrieving resources * fix
This commit is contained in:
parent
9b5ce3560c
commit
a3e6ba2eef
@ -38,6 +38,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
@ -60,10 +61,10 @@ public final class CommonUtil {
|
||||
public static List<String> getResources(Pattern pattern) throws IOException {
|
||||
ArrayList<String> resources = new ArrayList<>();
|
||||
String classPath = System.getProperty("java.class.path", ".");
|
||||
List<String> classPathElements =
|
||||
Set<String> classPathElements =
|
||||
Arrays.stream(classPath.split(File.pathSeparator))
|
||||
.filter(jarName -> JAR_NAME_FILTER.stream().anyMatch(jarName.toLowerCase()::contains))
|
||||
.toList();
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
for (String element : classPathElements) {
|
||||
File file = new File(element);
|
||||
@ -84,6 +85,7 @@ public final class CommonUtil {
|
||||
}
|
||||
|
||||
private static Collection<String> getResourcesFromJarFile(File file, Pattern pattern) {
|
||||
LOG.debug("Adding from file {}", file);
|
||||
ArrayList<String> retval = new ArrayList<>();
|
||||
try (ZipFile zf = new ZipFile(file)) {
|
||||
Enumeration<? extends ZipEntry> e = zf.entries();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user