@@ -45,11 +45,7 @@ public class AvroAnnotationIntrospector extends AnnotationIntrospector
45
45
{
46
46
private static final long serialVersionUID = 1L ;
47
47
48
- protected final boolean _useEnhancedTyping ;
49
-
50
- public AvroAnnotationIntrospector () {
51
- _useEnhancedTyping = true ;
52
- }
48
+ public AvroAnnotationIntrospector () { }
53
49
54
50
@ Override
55
51
public Version version () {
@@ -168,10 +164,11 @@ public TypeResolverBuilder<?> findPropertyContentTypeResolver(MapperConfig<?> co
168
164
}
169
165
170
166
protected TypeResolverBuilder <?> _findTypeResolver (MapperConfig <?> config , Annotated ann , JavaType baseType ) {
171
- // 14-Apr-2017, tatu: Only enable polymorphic type handling if explicitly annotated; otherwise
172
- // we have no way to determine this. Part of the problem is that we have no access to
173
- // schema infomration here, which would contain information.
174
- if (_useEnhancedTyping || (_getUnionTypes (ann ) != null )) {
167
+ // 14-Apr-2017, tatu: There are two ways to enable polymorphic typing, above and beyond
168
+ // basic Jackson: use of `@Union`, and "default typing" approach for `java.lang.Object`:
169
+ // latter since Avro support for "untyped" values is otherwise difficult.
170
+ // This seems to work for now, but maybe needs more work in future...
171
+ if (baseType .isJavaLangObject () || (_getUnionTypes (ann ) != null )) {
175
172
TypeResolverBuilder <?> resolver = new AvroTypeResolverBuilder ();
176
173
JsonTypeInfo typeInfo = ann .getAnnotation (JsonTypeInfo .class );
177
174
if (typeInfo != null && typeInfo .defaultImpl () != JsonTypeInfo .class ) {
0 commit comments