You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by cw...@apache.org on 2010/04/07 19:11:38 UTC
svn commit: r931620 -
/incubator/uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/aae/jmx/monitor/JmxMonitor.java
Author: cwiklik
Date: Wed Apr 7 17:11:38 2010
New Revision: 931620
URL: http://svn.apache.org/viewvc?rev=931620&view=rev
Log:
UIMA-1680 Fixed NPE
Modified:
incubator/uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/aae/jmx/monitor/JmxMonitor.java
Modified: incubator/uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/aae/jmx/monitor/JmxMonitor.java
URL: http://svn.apache.org/viewvc/incubator/uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/aae/jmx/monitor/JmxMonitor.java?rev=931620&r1=931619&r2=931620&view=diff
==============================================================================
--- incubator/uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/aae/jmx/monitor/JmxMonitor.java (original)
+++ incubator/uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/aae/jmx/monitor/JmxMonitor.java Wed Apr 7 17:11:38 2010
@@ -390,9 +390,9 @@ public class JmxMonitor implements Runna
protected ServiceMetrics[] collectStats(boolean initial, long uptime) {
int cmFreeCasInstanceCount = 0;
- ServiceMetrics[] metrics = new ServiceMetrics[servicePerformanceNames.size()];
+ ServiceMetrics[] metrics = null;
int index = 0;
-
+ List<ServiceMetrics> metricsList = new ArrayList<ServiceMetrics>();
// iterate over all Performance MBeans to retrieve current metrics
for (ObjectName name : servicePerformanceNames) {
try {
@@ -494,7 +494,8 @@ public class JmxMonitor implements Runna
// Add metrics collected from the service to the array of metrics
// in the current sampling (interval). The metrics array will
// be provided to all listeners plugged into this monitor.
- metrics[index++] = serviceMetrics;
+// metrics[index++] = serviceMetrics;
+ metricsList.add(serviceMetrics);
// Save current metrics for the next delta
entry.setIdleTime(idleTime);
entry.incrementCASCount(processCount);
@@ -507,8 +508,11 @@ public class JmxMonitor implements Runna
"UIMAJMS_exception__WARNING", e);
}
}
-
} // for
+ if ( metricsList.size() > 0 ) {
+ metrics = new ServiceMetrics[metricsList.size()];
+ metricsList.toArray(metrics);
+ }
return metrics;
}
@@ -534,9 +538,11 @@ public class JmxMonitor implements Runna
}
}
ServiceMetrics[] metrics = collectStats(initial, uptime);
- initial = false;
- // Notify listeners with current metrics collected from MBeans
- notifyListeners(uptime, metrics);
+ if ( metrics != null ) {
+ initial = false;
+ // Notify listeners with current metrics collected from MBeans
+ notifyListeners(uptime, metrics);
+ }
// compute wait time till next sample
long sampleEnd = System.nanoTime();