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/12/04 14:02:58 UTC

[GitHub] [netbeans] sdedic commented on a change in pull request #1739: Avoid lookup query in logging which may lead to deadlocks

sdedic commented on a change in pull request #1739: Avoid lookup query in logging which may lead to deadlocks
URL: https://github.com/apache/netbeans/pull/1739#discussion_r353760240
 
 

 ##########
 File path: platform/core.startup/src/org/netbeans/core/startup/TopLogging.java
 ##########
 @@ -401,41 +401,47 @@ static void exit(int exit) {
         TopSecurityManager.exit(exit);
     }
 
-    private static final class LookupDel extends Handler
-    implements LookupListener {
-        private Lookup.Result<Handler> handlers;
+    static void exit(int exit, Throwable t) {
+        t.printStackTrace(OLD_ERR);
+        exit(exit);
+    }
+
+    private static final class LookupDel extends Handler {
+        private final Lookup.Result<Handler> handlers;
         private Collection<? extends Handler> instances;
 
 
-        public LookupDel() {
+        LookupDel() {
             handlers = Lookup.getDefault().lookupResult(Handler.class);
-            instances = handlers.allInstances();
-            instances.size(); // initialize
-            handlers.addLookupListener(this);
+            LookupListener onChange = (__) -> {
+                instances = new ArrayList<>(handlers.allInstances());
 
 Review comment:
   Very tricky !
   I'd suggest to add some non-normative warning to Open API docs so dumb Lookup users as myself are aware that the collection "that never changes contents" MAY be lazy computed, so it may call out on 1st content access.

----------------------------------------------------------------
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