You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the JSON provided from the server is an Array that contains nulls, for example:
this exception is thrown:
Caused by: java.lang.IllegalStateException: Could not convert value in array at "addressLines" to java.lang.Object from null.
This seems to happen because in the method parseFlatJsonArray, under the file JsonParserUtils.java, there's this code that throws an exception, since null is never an instance of Object.
if (typeClass.isInstance(nextValue)) {
// This is safe since we are calling class.isInstance()@SuppressWarnings("unchecked")
TtoAdd = (T) nextValue;
collection.add(toAdd);
} else {
thrownewIllegalStateException(
String.format(Locale.US,
"Could not convert value in array at \"%s\" to %s from %s.",
key,
typeClass.getCanonicalName(),
getClassName(nextValue)));
}
So Nathan, I wanted to ask your opinion of whether we should change this code to pass over the nulls and not throw an exception here, or if we need to leave it like this because it's expected to throw an exception if there are null values.
The text was updated successfully, but these errors were encountered:
I don't think there would be any problem with allowing nulls in Collections. The only issue you might run into is if the Collection in question does not allow nulls as items, but then the client at least has the object to use a different implementation of Collection.
We would also need to make sure that a null in a Collection of Collections is allowed.
When the JSON provided from the server is an Array that contains nulls, for example:
this exception is thrown:
This seems to happen because in the method parseFlatJsonArray, under the file JsonParserUtils.java, there's this code that throws an exception, since null is never an instance of Object.
So Nathan, I wanted to ask your opinion of whether we should change this code to pass over the nulls and not throw an exception here, or if we need to leave it like this because it's expected to throw an exception if there are null values.
The text was updated successfully, but these errors were encountered: