I had some trouble understanding the rationale behind
|
@Override |
|
public JsonNullable<Object> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { |
|
JsonToken t = p.getCurrentToken(); |
|
if (t == JsonToken.VALUE_STRING && !_fullType.isTypeOrSubTypeOf(String.class)) { |
|
String str = p.getText().trim(); |
|
if (str.isEmpty()) { |
|
return JsonNullable.undefined(); |
|
} |
|
} |
|
return super.deserialize(p, ctxt); |
|
} |
and took a closer look on the code and tests. I think that the check in line 40 should compare the generic type of JsonNullable rather than the _fullType - otherwise it would replace empty/whitespace strings with JsonNullable.undefined() for any type, since _fullType always is JsonNullable in the Deserializer.
Unfortunately there was no test covering the null/empty string case for JsonNullable, so this behaviour kept undiscovered.
I`ll submit a pull request to fix that bug / add additonal tests to cover the case and would be happy to see it upstream soon if you agree.
Thanks,
Jakob
I had some trouble understanding the rationale behind
jackson-databind-nullable/src/main/java/org/openapitools/jackson/nullable/JsonNullableDeserializer.java
Lines 37 to 47 in b4e4874
and took a closer look on the code and tests. I think that the check in line 40 should compare the generic type of
JsonNullablerather than the_fullType- otherwise it would replace empty/whitespace strings withJsonNullable.undefined()for any type, since_fullTypealways isJsonNullablein the Deserializer.Unfortunately there was no test covering the null/empty string case for JsonNullable, so this behaviour kept undiscovered.
I`ll submit a pull request to fix that bug / add additonal tests to cover the case and would be happy to see it upstream soon if you agree.
Thanks,
Jakob