platform: JarLoader prevented from using ZIP file cache
authorRoman Shevchenko <roman.shevchenko@jetbrains.com>
Mon, 23 Feb 2015 12:34:41 +0000 (13:34 +0100)
committerRoman Shevchenko <roman.shevchenko@jetbrains.com>
Mon, 23 Feb 2015 12:34:41 +0000 (13:34 +0100)
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.

platform/bootstrap/src/com/intellij/ide/BootstrapClassLoaderUtil.java
platform/util/src/com/intellij/openapi/util/io/ZipFileCache.java

index 29a8905a45b9f737c7238d336ff627d1243691af..3bd742189c07005cece469c60258b79d8b696de2 100644 (file)
@@ -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"))) {
index bf98c0f63b6d290a249a2badf069178d9942e705..65a7ee3988a77a30178fa0c8382126774a6fdd1f 100644 (file)
@@ -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) {