diff --git a/release-notes/VERSION b/release-notes/VERSION index 0273681..f70bcb4 100644 --- a/release-notes/VERSION +++ b/release-notes/VERSION @@ -4,6 +4,10 @@ Project: jackson-datatype-guava === History: === ------------------------------------------------------------------------ +2.4.7 (not released) + +#48: Avoid problems deserializing `null` for `Optional` + 2.4.6 (23-Apr-2015) #61: NPE serializing `Multimap`s with null values diff --git a/src/main/java/com/fasterxml/jackson/datatype/guava/deser/GuavaOptionalDeserializer.java b/src/main/java/com/fasterxml/jackson/datatype/guava/deser/GuavaOptionalDeserializer.java index 5462b11..e03ddfe 100644 --- a/src/main/java/com/fasterxml/jackson/datatype/guava/deser/GuavaOptionalDeserializer.java +++ b/src/main/java/com/fasterxml/jackson/datatype/guava/deser/GuavaOptionalDeserializer.java @@ -99,7 +99,7 @@ public Optional deserialize(JsonParser jp, DeserializationContext ctxt) throw } else { refd = _valueDeserializer.deserializeWithType(jp, ctxt, _valueTypeDeserializer); } - return Optional.of(refd); + return Optional.fromNullable(refd); } /* NOTE: usually should not need this method... but for some reason, it is needed here. @@ -121,6 +121,6 @@ public Optional deserializeWithType(JsonParser jp, DeserializationContext ctx return deserialize(jp, ctxt); } // with type deserializer to use here? Looks like we get passed same one? - return Optional.of(typeDeserializer.deserializeTypedFromAny(jp, ctxt)); + return Optional.fromNullable(typeDeserializer.deserializeTypedFromAny(jp, ctxt)); } } \ No newline at end of file