From 7b5c7b7ab725dd58ddf1ba0deb674e12b2d102bb Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 22 Sep 2014 00:01:42 -0700 Subject: [PATCH] One last (?) fix to schema access for GuavaOptionalSerializer --- .../guava/ser/GuavaOptionalSerializer.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/fasterxml/jackson/datatype/guava/ser/GuavaOptionalSerializer.java b/src/main/java/com/fasterxml/jackson/datatype/guava/ser/GuavaOptionalSerializer.java index 591dc4e..bed4598 100644 --- a/src/main/java/com/fasterxml/jackson/datatype/guava/ser/GuavaOptionalSerializer.java +++ b/src/main/java/com/fasterxml/jackson/datatype/guava/ser/GuavaOptionalSerializer.java @@ -113,13 +113,16 @@ public void serializeWithType(Optional value, @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { - JavaType typeParameter = typeHint.containedType(0); - if (typeParameter != null) { - JsonSerializer ser = visitor.getProvider().findValueSerializer(typeParameter, null); - ser.acceptJsonFormatVisitor(visitor, typeParameter); - return; + JavaType valueType = _valueType(); + if (valueType != null) { + JsonSerializer ser = _valueSerializer; + if (ser == null) { + ser = visitor.getProvider().findValueSerializer(valueType, null); + } + ser.acceptJsonFormatVisitor(visitor, valueType); + } else { + super.acceptJsonFormatVisitor(visitor, typeHint); } - super.acceptJsonFormatVisitor(visitor, typeHint); } protected JavaType _valueType() {