Skip to content

Commit 05bc938

Browse files
committed
Minor tweak; instead of configurable "enhanced type handling", use heuristic that "untyped" (java.lang.Object) should enable it; in addition to @Union
1 parent 9f3cdae commit 05bc938

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroAnnotationIntrospector.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ public class AvroAnnotationIntrospector extends AnnotationIntrospector
4545
{
4646
private static final long serialVersionUID = 1L;
4747

48-
protected final boolean _useEnhancedTyping;
49-
50-
public AvroAnnotationIntrospector() {
51-
_useEnhancedTyping = true;
52-
}
48+
public AvroAnnotationIntrospector() { }
5349

5450
@Override
5551
public Version version() {
@@ -168,10 +164,11 @@ public TypeResolverBuilder<?> findPropertyContentTypeResolver(MapperConfig<?> co
168164
}
169165

170166
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)) {
175172
TypeResolverBuilder<?> resolver = new AvroTypeResolverBuilder();
176173
JsonTypeInfo typeInfo = ann.getAnnotation(JsonTypeInfo.class);
177174
if (typeInfo != null && typeInfo.defaultImpl() != JsonTypeInfo.class) {

0 commit comments

Comments
 (0)