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 {
final CodeSource codeSource = SystemSchema.class.getProtectionDomain().getCodeSource();
final ClassLoader classLoader = SystemSchema.class.getClassLoader();
final String location = codeSource.getLocation().toString();
final Enumeration<URL> urls;
InputStream inputStream = SystemSchema.class.getClassLoader().getResourceAsStream(name);
urls = classLoader.getResources(name);
while (urls.hasMoreElements()) {
final URL url = urls.nextElement();
if (url.getFile().endsWith(name)) {
return url.openStream();
}
if (inputStream != null) {
return inputStream;
}
throw new FileNotFoundException(lenientFormat("cannot find %s at %s", name, location));
throw new FileNotFoundException(lenientFormat("cannot find %s", name));
}
}