mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Avoid opening InputStream via URL when calling super.getResourceAsStream
When bootstrap resources are supported delegating to super.getResourceAsStream() will cause opening InputStreams from URL. This isn't as efficient as own UrlClassLoader's capability to use existing open ZipFile handles GitOrigin-RevId: 48fa777911b29196899275119c6ccabbebca9afc
This commit is contained in:
committed by
intellij-monorepo-bot
parent
867986fa4d
commit
4c9fb78cb0
@@ -63,7 +63,6 @@ public class UrlClassLoader extends ClassLoader {
|
||||
@SuppressWarnings("unused")
|
||||
void appendToClassPathForInstrumentation(String jar) {
|
||||
try {
|
||||
//noinspection deprecation
|
||||
addURL(new File(jar).toURI().toURL());
|
||||
} catch(MalformedURLException ignore) {}
|
||||
}
|
||||
@@ -345,8 +344,11 @@ public class UrlClassLoader extends ClassLoader {
|
||||
return defineClass(name, b, 0, b.length, protectionDomain);
|
||||
}
|
||||
|
||||
private static final ThreadLocal<Boolean> ourSkipFindingResource = new ThreadLocal<Boolean>();
|
||||
|
||||
@Override
|
||||
public URL findResource(String name) {
|
||||
if (ourSkipFindingResource.get() != null) return null;
|
||||
Resource res = findResourceImpl(name);
|
||||
return res != null ? res.getURL() : null;
|
||||
}
|
||||
@@ -365,7 +367,13 @@ public class UrlClassLoader extends ClassLoader {
|
||||
@Override
|
||||
public InputStream getResourceAsStream(String name) {
|
||||
if (myAllowBootstrapResources) {
|
||||
return super.getResourceAsStream(name);
|
||||
ourSkipFindingResource.set(Boolean.TRUE);
|
||||
try {
|
||||
InputStream stream = super.getResourceAsStream(name);
|
||||
if (stream != null) return stream;
|
||||
} finally {
|
||||
ourSkipFindingResource.set(null);
|
||||
}
|
||||
}
|
||||
try {
|
||||
Resource res = findResourceImpl(name);
|
||||
|
||||
Reference in New Issue
Block a user