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
(Noticed by @sergiitk in #8871 (comment)) The current implementation of JsonUtil.getObject() will throw ClassCastException if the input contains the key with an explicit null value.
/** * Gets an object from an object for the given key. If the key is not present, this returns null. * If the value is not a Map, throws an exception. */@SuppressWarnings("unchecked")
@NullablepublicstaticMap<String, ?> getObject(Map<String, ?> obj, Stringkey) {
assertkey != null;
if (!obj.containsKey(key)) {
returnnull;
}
Objectvalue = obj.get(key);
if (!(valueinstanceofMap)) {
thrownewClassCastException(
String.format("value '%s' for key '%s' in '%s' is not object", value, key, obj));
}
return (Map<String, ?>) value;
}
The text was updated successfully, but these errors were encountered:
What is the problem here? Failing seems appropriate. If a key is set it needs to have the right type and null isn't the right type. There seems to be no purpose to allowing the values to be set to nulland to treat that as not present.
Verifies the behavior of JsonUtil.getObject when the map contains a null value for a given key.
Note: this may be incorrect behavior. Issue to track the investigation: #8883.
(Noticed by @sergiitk in #8871 (comment)) The current implementation of
JsonUtil.getObject()
will throwClassCastException
if the input contains the key with an explicit null value.The text was updated successfully, but these errors were encountered: