You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2019/09/10 13:28:31 UTC

[GitHub] [netbeans] lkishalmi commented on a change in pull request #1422: [NETBEANS-2940] Cache ArchiveRootProviders

lkishalmi commented on a change in pull request #1422: [NETBEANS-2940] Cache ArchiveRootProviders
URL: https://github.com/apache/netbeans/pull/1422#discussion_r322742125
 
 

 ##########
 File path: platform/openide.filesystems/src/org/openide/filesystems/FileUtil.java
 ##########
 @@ -2323,17 +2324,24 @@ private static boolean isArchiveFileImpl(final URL url, final boolean strict) {
     }
 
     private static Iterable<? extends ArchiveRootProvider> getArchiveRootProviders() {
-        Lookup.Result<ArchiveRootProvider> res = archiveRootProviders.get();
-        if (res == null) {
-            res = new ProxyLookup(
-                Lookups.singleton(new JarArchiveRootProvider()),
-                Lookup.getDefault()).lookupResult(ArchiveRootProvider.class);
-            if (!archiveRootProviders.compareAndSet(null, res)) {
-                res = archiveRootProviders.get();
+        if (archiveRootProviderCache == null) {
+            Lookup.Result<ArchiveRootProvider> res = archiveRootProviders.get();
+            if (res == null) {
+                res = new ProxyLookup(
+                    Lookups.singleton(new JarArchiveRootProvider()),
+                    Lookup.getDefault()).lookupResult(ArchiveRootProvider.class);
+                if (!archiveRootProviders.compareAndSet(null, res)) {
+                    res = archiveRootProviders.get();
+                    res.addLookupListener((ev) -> {
+                        archiveRootProviderCache = null;
+                    });
+                }
             }
+            archiveRootProviderCache = new LinkedList<>(res.allInstances());
         }
-        return res.allInstances();
+        return archiveRootProviderCache;
 
 Review comment:
   In Line 2335 we add a listener to the lookup result, so if new Archive providers would be registered in the system the cache would be invalidated and it's content would be re-read. Also so far there are 2 ArchiveRootProvider implementations in the system one for jars and one for jrt-s.
   Profile snapshots attached to NETBEANS-2940 shows that NetBeans can spend considerable amount of time searching the non-jar provider almost every time when an archive root has to be evaluated.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists