Repository: wicket
Updated Branches:
  refs/heads/wicket-7.x 10cb9326f -> d9c05b460


WICKET-6400 Object with array property fails on NPE when construction JSON 
object


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/d9c05b46
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/d9c05b46
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/d9c05b46

Branch: refs/heads/wicket-7.x
Commit: d9c05b460755a2a8b0519806647ec7e031f2a8a5
Parents: 10cb932
Author: Martin Tzvetanov Grigorov <[email protected]>
Authored: Thu Jun 22 21:51:33 2017 +0200
Committer: Martin Tzvetanov Grigorov <[email protected]>
Committed: Thu Jun 22 21:51:33 2017 +0200

----------------------------------------------------------------------
 .../java/org/apache/wicket/ajax/json/JSONObject.java     | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/d9c05b46/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONObject.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONObject.java 
b/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONObject.java
index 39f56c5..ac840bc 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONObject.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONObject.java
@@ -227,6 +227,11 @@ public class JSONObject {
 
     private static Map<String, Object> propertiesAsMap(Object bean) throws 
JSONException {
         Map<String, Object> props = new TreeMap<String, Object>();
+
+        if (bean instanceof JSONArray) {
+            return props;
+        }
+
         try {
             PropertyDescriptor[] properties = 
Introspector.getBeanInfo(bean.getClass(), Object.class)
                     .getPropertyDescriptors();
@@ -234,11 +239,7 @@ public class JSONObject {
                 Object v = prop.getReadMethod().invoke(bean);
                 props.put(prop.getDisplayName(), wrap(v));
             }
-        } catch (IllegalAccessException e) {
-            throw new JSONException(e);
-        } catch (IntrospectionException e) {
-            throw new JSONException(e);
-        } catch (InvocationTargetException e) {
+        } catch (IllegalAccessException | IntrospectionException | 
InvocationTargetException e) {
             throw new JSONException(e);
         }
         return props;

Reply via email to