commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nico...@apache.org
Subject svn commit: r745905 - /commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/AbstractMonitor.java
Date Thu, 19 Feb 2009 15:50:43 GMT
Author: nicolas
Date: Thu Feb 19 15:50:42 2009
New Revision: 745905

URL: http://svn.apache.org/viewvc?rev=745905&view=rev
Log:
fix NullPointer

Modified:
    commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/AbstractMonitor.java

Modified: commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/AbstractMonitor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/AbstractMonitor.java?rev=745905&r1=745904&r2=745905&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/AbstractMonitor.java
(original)
+++ commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/AbstractMonitor.java
Thu Feb 19 15:50:42 2009
@@ -33,10 +33,12 @@
  *
  * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
  */
-public abstract class AbstractMonitor implements Monitor
+public abstract class AbstractMonitor
+    implements Monitor
 {
 
     private final ConcurrentMap<Role, Metric> metrics;
+
     private final Key key;
 
     public AbstractMonitor( Key key )
@@ -70,11 +72,15 @@
      */
     public final Metric getMetric( String role )
     {
-        return metrics.get( Role.getRole( role ) );
+        return getMetric( Role.getRole( role ) );
     }
 
     public final Metric getMetric( Role role )
     {
+        if ( role == null )
+        {
+            return null;
+        }
         return metrics.get( role );
     }
 
@@ -93,7 +99,7 @@
      *
      * @param metric Metric instance to get registered
      * @return a previously registered Metric if existed, or <code>null</code>
if the metric has been successfully
-     * registered
+     *         registered
      */
     protected Metric register( Metric metric )
     {



Mime
View raw message