This is an automated email from the ASF dual-hosted git repository.
lkishalmi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new 290420c [NETBEANS-2940] Cache ArchiveRootProviders
290420c is described below
commit 290420cfff1af3f72dd5eb86f864edd74ff78fe8
Author: Laszlo Kishalmi <[email protected]>
AuthorDate: Mon Aug 12 16:19:01 2019 -0700
[NETBEANS-2940] Cache ArchiveRootProviders
---
.../src/org/openide/filesystems/FileUtil.java | 24 ++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git
a/platform/openide.filesystems/src/org/openide/filesystems/FileUtil.java
b/platform/openide.filesystems/src/org/openide/filesystems/FileUtil.java
index ea7fd8d..ada584a 100644
--- a/platform/openide.filesystems/src/org/openide/filesystems/FileUtil.java
+++ b/platform/openide.filesystems/src/org/openide/filesystems/FileUtil.java
@@ -41,6 +41,7 @@ import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
@@ -2323,17 +2324,24 @@ public final class FileUtil extends Object {
}
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;
}
+ private static Iterable<? extends ArchiveRootProvider>
archiveRootProviderCache;
private static final AtomicReference<Lookup.Result<ArchiveRootProvider>>
archiveRootProviders = new AtomicReference<>();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists