tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1234567 - /tomcat/trunk/java/org/apache/catalina/manager/JMXProxyServlet.java
Date Sun, 22 Jan 2012 18:31:01 GMT
Author: markt
Date: Sun Jan 22 18:31:00 2012
New Revision: 1234567

URL: http://svn.apache.org/viewvc?rev=1234567&view=rev
Log:
Better handling when MBean ops return null.
Patch by kkolinko

Modified:
    tomcat/trunk/java/org/apache/catalina/manager/JMXProxyServlet.java

Modified: tomcat/trunk/java/org/apache/catalina/manager/JMXProxyServlet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/manager/JMXProxyServlet.java?rev=1234567&r1=1234566&r2=1234567&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/manager/JMXProxyServlet.java (original)
+++ tomcat/trunk/java/org/apache/catalina/manager/JMXProxyServlet.java Sun Jan 22 18:31:00
2012
@@ -126,8 +126,14 @@ public class JMXProxyServlet extends Htt
         try {
             ObjectName oname = new ObjectName(onameStr);
             Object value = mBeanServer.getAttribute(oname, att);
+            String valueStr;
+            if (value != null) {
+                valueStr = value.toString();
+            } else {
+                valueStr = "<null>";
+            }
             writer.println("OK - Attribute get '" + onameStr + "' - " + att
-                    + "= " + MBeanDumper.escape(value.toString()));
+                    + "= " + MBeanDumper.escape(valueStr));
         } catch (Exception ex) {
             writer.println("Error - " + ex.toString());
             ex.printStackTrace(writer);
@@ -193,8 +199,12 @@ public class JMXProxyServlet extends Htt
            }
 
             Object retVal = mBeanServer.invoke(oname,op,values,signatureTypes);
-            writer.println("OK - Operation " + op + " returned:");
-            output("", writer, retVal);
+            if (retVal != null) {
+                writer.println("OK - Operation " + op + " returned:");
+                output("", writer, retVal);
+            } else {
+                writer.println("OK - Operation " + op + " without return value");
+            }
         } catch( Exception ex ) {
             writer.println("Error - " + ex.toString());
             ex.printStackTrace(writer);
@@ -207,7 +217,13 @@ public class JMXProxyServlet extends Htt
                 output("  " + indent, writer, obj);
             }
         } else {
-            writer.println(indent + result.toString());
+            String strValue;
+            if (result != null) {
+                strValue = result.toString();
+            } else {
+                strValue = "<null>";
+            }
+            writer.println(indent + strValue);
         }
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message