mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
platform: JarLoader prevented from using ZIP file cache
First, this effectively doesn't change the behavior - as ZipFileCache was effectively disabled by a (somewhat inconvenient) condition in it. Next, this allows to drop the condition while still preventing it from loading at bootstrap.
This commit is contained in:
@@ -62,7 +62,7 @@ public class BootstrapClassLoaderUtil extends ClassUtilCore {
|
||||
|
||||
UrlClassLoader.Builder builder = UrlClassLoader.build()
|
||||
.urls(filterClassPath(classpath))
|
||||
.allowLock()
|
||||
.allowLock(false)
|
||||
.usePersistentClasspathIndexForLocalClassDirectories()
|
||||
.useCache();
|
||||
if (Boolean.valueOf(System.getProperty(PROPERTY_ALLOW_BOOTSTRAP_RESOURCES, "true"))) {
|
||||
|
||||
@@ -68,9 +68,6 @@ public class ZipFileCache {
|
||||
}
|
||||
}
|
||||
|
||||
private static final boolean ourEnabled =
|
||||
ZipFileCache.class.getClassLoader().getResource("com/intellij/openapi/application/Application.class") != null;
|
||||
|
||||
private static final Object ourLock = new Object();
|
||||
private static final Map<String, CacheRecord> ourPathCache = ContainerUtil.newTroveMap(FileUtil.PATH_HASHING_STRATEGY);
|
||||
private static final Map<ZipFile, CacheRecord> ourFileCache = ContainerUtil.newHashMap();
|
||||
@@ -79,29 +76,20 @@ public class ZipFileCache {
|
||||
private static final ScheduledThreadPoolExecutor ourExecutor;
|
||||
|
||||
static {
|
||||
if (ourEnabled) {
|
||||
ourExecutor = ConcurrencyUtil.newSingleScheduledThreadExecutor("ZipFileCache Dispose", Thread.MIN_PRIORITY);
|
||||
ourExecutor.scheduleWithFixedDelay(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
List<ZipFile> toClose = getFilesToClose(0, System.currentTimeMillis() - TIMEOUT);
|
||||
if (toClose != null) {
|
||||
close(toClose);
|
||||
}
|
||||
ourExecutor = ConcurrencyUtil.newSingleScheduledThreadExecutor("ZipFileCache Dispose", Thread.MIN_PRIORITY);
|
||||
ourExecutor.scheduleWithFixedDelay(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
List<ZipFile> toClose = getFilesToClose(0, System.currentTimeMillis() - TIMEOUT);
|
||||
if (toClose != null) {
|
||||
close(toClose);
|
||||
}
|
||||
}, PERIOD, PERIOD, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
else {
|
||||
ourExecutor = null;
|
||||
}
|
||||
}
|
||||
}, PERIOD, PERIOD, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ZipFile acquire(@NotNull String path) throws IOException {
|
||||
if (!ourEnabled) {
|
||||
return new ZipFile(path);
|
||||
}
|
||||
|
||||
path = FileUtil.toCanonicalPath(path);
|
||||
|
||||
synchronized (ourLock) {
|
||||
@@ -178,11 +166,6 @@ public class ZipFileCache {
|
||||
}
|
||||
|
||||
public static void release(@NotNull ZipFile file) {
|
||||
if (!ourEnabled) {
|
||||
close(file);
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (ourLock) {
|
||||
CacheRecord record = ourFileCache.get(file);
|
||||
if (record != null) {
|
||||
|
||||
Reference in New Issue
Block a user