[hornetq-commits] JBoss hornetq SVN: r11995 - trunk/hornetq-core/src/main/java/org/hornetq/utils/json.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Jan 6 14:21:22 EST 2012


Author: borges
Date: 2012-01-06 14:21:21 -0500 (Fri, 06 Jan 2012)
New Revision: 11995

Modified:
   trunk/hornetq-core/src/main/java/org/hornetq/utils/json/JSONObject.java
Log:
Fix warnings, and clarify code.

Modified: trunk/hornetq-core/src/main/java/org/hornetq/utils/json/JSONObject.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/utils/json/JSONObject.java	2012-01-06 19:21:02 UTC (rev 11994)
+++ trunk/hornetq-core/src/main/java/org/hornetq/utils/json/JSONObject.java	2012-01-06 19:21:21 UTC (rev 11995)
@@ -57,11 +57,11 @@
  * do type checking and type coercion for you.
  * <p>
  * The <code>put</code> methods adds values to an object. For example,
- * 
+ *
  * <pre>
  * myString = new JSONObject().put(&quot;JSON&quot;, &quot;Hello, World!&quot;).toString();
  * </pre>
- * 
+ *
  * produces the string <code>{"JSON": "Hello, World"}</code>.
  * <p>
  * The texts produced by the <code>toString</code> methods strictly conform to the JSON syntax
@@ -1571,20 +1571,18 @@
       }
       if (value instanceof JSONString)
       {
-         Object o;
+         String o;
          try
          {
             o = ((JSONString)value).toJSONString();
          }
-         catch (Exception e)
+         catch (RuntimeException e)
          {
             throw new JSONException(e);
          }
-         if (o instanceof String)
-         {
-            return (String)o;
-         }
-         throw new JSONException("Bad value from toJSONString: " + o);
+         if (o == null)
+            throw new JSONException("Bad value from toJSONString: " + o);
+         return o;
       }
       if (value instanceof Number)
       {
@@ -1633,14 +1631,12 @@
       {
          if (value instanceof JSONString)
          {
-            Object o = ((JSONString)value).toJSONString();
-            if (o instanceof String)
-            {
-               return (String)o;
-            }
+            String o = ((JSONString)value).toJSONString();
+            if (o != null)
+               return o;
          }
       }
-      catch (Exception e)
+      catch (RuntimeException e)
       {
          /* forget about it */
       }



More information about the hornetq-commits mailing list