[hg] main-silver: #223093: Prevent from NPE when there is a null...

  • From:
  • To:
  • Subject: [hg] main-silver: #223093: Prevent from NPE when there is a null...
  • Date: Mon, 17 Dec 2012 14:37:56 -0800

changeset 565c9ba06532 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/565c9ba06532
description:
        #223093: Prevent from NPE when there is a null action provider in the 
lookup list. Also log a problem with creating a service from the lookup.

diffstat:

 api.debugger/src/org/netbeans/api/debugger/ActionsManager.java |  27 
+++++++--
 api.debugger/src/org/netbeans/api/debugger/Lookup.java         |   1 +
 2 files changed, 20 insertions(+), 8 deletions(-)

diffs (83 lines):

diff --git a/api.debugger/src/org/netbeans/api/debugger/ActionsManager.java 
b/api.debugger/src/org/netbeans/api/debugger/ActionsManager.java
--- a/api.debugger/src/org/netbeans/api/debugger/ActionsManager.java
+++ b/api.debugger/src/org/netbeans/api/debugger/ActionsManager.java
@@ -145,7 +145,7 @@
      */
     ActionsManager (Lookup lookup) {
         this.lookup = lookup;
-        logger.log(Level.INFO, "new ActionsManager({0}) = {1}", new Object[] 
{ lookup, this });
+        logger.log(Level.FINE, "new ActionsManager({0}) = {1}", new Object[] 
{ lookup, this });
     }
     
     
@@ -494,18 +494,29 @@
         synchronized (aps) {
             if (logger.isLoggable(Level.INFO)) {
                 StringBuilder sb = new StringBuilder(this.toString());
+                boolean isNull = false;
                 sb.append(".registerActionsProviders:");
                 for (ActionsProvider ap : aps) {
                     sb.append("\n  ");
-                    sb.append(ap != null ? ap.toString() : "NULL element in 
list " + System.identityHashCode(aps)); // NOI18N
+                    if (ap != null) {
+                        sb.append(ap.toString());
+                    } else {
+                        sb.append("NULL element in list " + 
Integer.toHexString(aps.hashCode())); // NOI18N
+                        isNull = true;
+                    }
                 }
                 sb.append("\n");
+                if (isNull) {
                 logger.info(sb.toString());
+                } else {
+                    logger.fine(sb.toString());
+                }
             }
             for (ActionsProvider ap : aps) {
-                Iterator ii = ap.getActions ().iterator ();
-                while (ii.hasNext ()) {
-                    registerActionsProvider (ii.next (), ap);
+                if (ap != null) {
+                    for (Object action : ap.getActions ()) {
+                        registerActionsProvider (action, ap);
+                    }
                 }
             }
         }
@@ -516,14 +527,14 @@
         providersChangeListener = new PropertyChangeListener() {
                 @Override
                 public void propertyChange(PropertyChangeEvent evt) {
-                    logger.log(Level.INFO, "{0} Providers lookup changed, 
aps = {1}", new Object[] { this, aps });
+                    logger.log(Level.FINE, "{0} Providers lookup changed, 
aps = {1}", new Object[] { this, aps });
                     synchronized (actionProvidersLock) {
                         actionProviders.clear();
                     }
                     registerActionsProviders(aps);
                 }
         };
-        logger.log(Level.INFO, "{0}.initActionImpls(): Add 
ProvidersChangeListener to {1}", new Object[] { this, aps });
+        logger.log(Level.FINE, "{0}.initActionImpls(): Add 
ProvidersChangeListener to {1}", new Object[] { this, aps });
         ((Customizer) 
aps).addPropertyChangeListener(providersChangeListener);
         registerActionsProviders(aps);
         synchronized (actionProvidersInitialized) {
@@ -563,7 +574,7 @@
     
     private void destroyIn () {
         ((Customizer) 
aps).removePropertyChangeListener(providersChangeListener);
-        logger.log(Level.INFO, "{0}.destroyIn(): ProvidersChangeListener 
removed from {1}", new Object[] { this, aps });
+        logger.log(Level.FINE, "{0}.destroyIn(): ProvidersChangeListener 
removed from {1}", new Object[] { this, aps });
         synchronized (this) {
             if (lazyListeners != null) {
                 int i, k = lazyListeners.size ();
diff --git a/api.debugger/src/org/netbeans/api/debugger/Lookup.java 
b/api.debugger/src/org/netbeans/api/debugger/Lookup.java
--- a/api.debugger/src/org/netbeans/api/debugger/Lookup.java
+++ b/api.debugger/src/org/netbeans/api/debugger/Lookup.java
@@ -1152,6 +1152,7 @@
                             }
                         }
                     } else {
+                        logger.log(Level.INFO, "Returning null instance from 
LazyInstance.getEntry(). className = {0}, service = {1}, lookupItem = {2}", 
new Object[]{ className, service, lookupItem });
                         return null;
                     }
                 }

[hg] main-silver: #223093: Prevent from NPE when there is a null...

mentlicher 12/17/2012

Project Features

About this Project

Debugger was started in November 2009, is owned by tpavek, and has 29 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close