todmorrison commented on a change in pull request #6629:
URL: https://github.com/apache/geode/pull/6629#discussion_r661695174



##########
File path: 
geode-core/src/main/java/org/apache/geode/pdx/internal/json/PdxToJSON.java
##########
@@ -224,9 +226,15 @@ private void getJSONStringFromArray(JsonGenerator jg, 
Object value, String pf)
         writeValue(jg, obj, pf);
       }
       jg.writeEndArray();
+    } else if (value.getClass().isArray()) {
+      throw new IllegalStateException(
+          "The pdx field " + pf + " is an array whose component type "
+              + value.getClass().getComponentType()
+              + " can not be converted to JSON.");
     } else {
       throw new IllegalStateException(
-          "PdxInstance returns unknown pdxfield " + pf + " for type " + value);
+          "Expected an array for pdx field " + pf + ", but got an object of 
type "

Review comment:
       Thanks, I did go back and forth about it, since it is a private method, 
but finally settled on playing it safe since even within a class when the lines 
of code increases assumptions can get lost. I do agree that the isArrary check 
should come first and, since I was already going to be doing another commit, 
went ahead and made the change. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to