camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1232435 - in /camel/branches/camel-2.9.x: ./ platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteInfo.java
Date Tue, 17 Jan 2012 15:10:34 GMT
Author: davsclaus
Date: Tue Jan 17 15:10:33 2012
New Revision: 1232435

URL: http://svn.apache.org/viewvc?rev=1232435&view=rev
Log:
CAMEL-4872: Fixed NPE in Camel Karaf command for route info. Thanks to Scott England-Sullivan
for the patch.

Modified:
    camel/branches/camel-2.9.x/   (props changed)
    camel/branches/camel-2.9.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteInfo.java

Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 17 15:10:33 2012
@@ -1 +1 @@
-/camel/trunk:1227209,1227212,1227540,1228015,1228027,1228223,1228879,1229565,1231135,1231704,1232309,1232312
+/camel/trunk:1227209,1227212,1227540,1228015,1228027,1228223,1228879,1229565,1231135,1231704,1232309,1232312,1232429

Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Jan 17 15:10:33 2012
@@ -1 +1 @@
-/camel/trunk:1-1227196,1227209,1227212,1227540,1228015,1228027,1228223,1228879,1229565,1231135,1231704,1232309,1232312
+/camel/trunk:1-1227196,1227209,1227212,1227540,1228015,1228027,1228223,1228879,1229565,1231135,1231704,1232309,1232312,1232429

Modified: camel/branches/camel-2.9.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteInfo.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteInfo.java?rev=1232435&r1=1232434&r2=1232435&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteInfo.java
(original)
+++ camel/branches/camel-2.9.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteInfo.java
Tue Jan 17 15:10:33 2012
@@ -92,11 +92,27 @@ public class RouteInfo extends OsgiComma
                 System.out.println(StringEscapeUtils.unescapeJava("\tTotal Processing Time:
" + totalProcessingTime + "ms"));
                 Long lastProcessingTime = (Long) mBeanServer.getAttribute(routeMBean, "LastProcessingTime");
                 System.out.println(StringEscapeUtils.unescapeJava("\tLast Processing Time:
" + lastProcessingTime + "ms"));
-                Date firstExchangeTimestamp = (Date) mBeanServer.getAttribute(routeMBean,
"FirstExchangeCompletedTimestamp");
+
+                // Test for null to see if a any exchanges have been processed first to avoid
NPE
+                Object firstExchangeTimestampObj = mBeanServer.getAttribute(routeMBean, "FirstExchangeCompletedTimestamp");
                 SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                System.out.println(StringEscapeUtils.unescapeJava("\tFirst Exchange Date:
" + format.format(firstExchangeTimestamp)));
-                Date lastExchangeCompletedTimestamp = (Date) mBeanServer.getAttribute(routeMBean,
"LastExchangeCompletedTimestamp");
-                System.out.println(StringEscapeUtils.unescapeJava("\tLast Exchange Completed
Date: " + format.format(lastExchangeCompletedTimestamp)));
+                if (firstExchangeTimestampObj == null) {
+                    // Print an empty value for scripting
+                    System.out.println(StringEscapeUtils.unescapeJava("\tFirst Exchange Date:"));
+                } else {
+                    Date firstExchangeTimestamp = (Date) firstExchangeTimestampObj;
+                    System.out.println(StringEscapeUtils.unescapeJava("\tFirst Exchange Date:
" + format.format(firstExchangeTimestamp)));
+                }
+
+                // Again, check for null to avoid NPE
+                Object lastExchangeCompletedTimestampObj = mBeanServer.getAttribute(routeMBean,
"LastExchangeCompletedTimestamp");
+                if (lastExchangeCompletedTimestampObj == null) {
+                    // Print an empty value for scripting
+                    System.out.println(StringEscapeUtils.unescapeJava("\tLast Exchange Completed
Date:"));
+                } else {
+                    Date lastExchangeCompletedTimestamp = (Date) lastExchangeCompletedTimestampObj;
+                    System.out.println(StringEscapeUtils.unescapeJava("\tLast Exchange Completed
Date: " + format.format(lastExchangeCompletedTimestamp)));
+                }
             }
         }
         System.out.println("");



Mime
View raw message