Simplified SystemSchema load process

This commit is contained in:
David Noble
2019-12-13 11:36:57 -08:00
parent 7de49efa03
commit 246745d047

View File

@@ -66,20 +66,12 @@ public final class SystemSchema {
private static InputStream getResourceAsStream(final String name) throws IOException { private static InputStream getResourceAsStream(final String name) throws IOException {
final CodeSource codeSource = SystemSchema.class.getProtectionDomain().getCodeSource(); InputStream inputStream = SystemSchema.class.getClassLoader().getResourceAsStream(name);
final ClassLoader classLoader = SystemSchema.class.getClassLoader();
final String location = codeSource.getLocation().toString();
final Enumeration<URL> urls;
urls = classLoader.getResources(name); if (inputStream != null) {
return inputStream;
while (urls.hasMoreElements()) {
final URL url = urls.nextElement();
if (url.getFile().endsWith(name)) {
return url.openStream();
}
} }
throw new FileNotFoundException(lenientFormat("cannot find %s at %s", name, location)); throw new FileNotFoundException(lenientFormat("cannot find %s", name));
} }
} }