@@ -62,11 +62,9 @@ public class RecordVisitor
62
62
*/
63
63
private final Schema _typeSchema ;
64
64
65
- // !!! 19-May-2025: TODO: make final in 2.20
66
- protected Schema _avroSchema ;
65
+ protected final Schema _avroSchema ;
67
66
68
- // !!! 19-May-2025: TODO: make final in 2.20
69
- protected List <Schema .Field > _fields = new ArrayList <>();
67
+ protected final List <Schema .Field > _fields = new ArrayList <>();
70
68
71
69
public RecordVisitor (SerializerProvider p , JavaType type , VisitorFormatWrapperImpl visitorWrapper )
72
70
{
@@ -82,12 +80,11 @@ public RecordVisitor(SerializerProvider p, JavaType type, VisitorFormatWrapperIm
82
80
_typeSchema = null ;
83
81
} else {
84
82
// If Avro schema for this _type results in UNION I want to know Avro type where to assign fields
85
- _avroSchema = AvroSchemaHelper .initializeRecordSchema (bean );
86
- _typeSchema = _avroSchema ;
83
+ _typeSchema = AvroSchemaHelper .initializeRecordSchema (bean );
87
84
_overridden = false ;
88
85
AvroMeta meta = bean .getClassInfo ().getAnnotation (AvroMeta .class );
89
86
if (meta != null ) {
90
- _avroSchema .addProp (meta .key (), meta .value ());
87
+ _typeSchema .addProp (meta .key (), meta .value ());
91
88
}
92
89
93
90
List <NamedType > subTypes = getProvider ().getAnnotationIntrospector ().findSubtypes (bean .getClassInfo ());
@@ -126,10 +123,12 @@ public RecordVisitor(SerializerProvider p, JavaType type, VisitorFormatWrapperIm
126
123
unionSchemas .add (subTypeSchema );
127
124
}
128
125
}
129
- _avroSchema = Schema .createUnion (new ArrayList <>(unionSchemas ));
130
126
} catch (JsonMappingException jme ) {
131
127
throw new RuntimeJsonMappingException ("Failed to build schema" , jme );
132
128
}
129
+ _avroSchema = Schema .createUnion (new ArrayList <>(unionSchemas ));
130
+ } else {
131
+ _avroSchema = _typeSchema ;
133
132
}
134
133
}
135
134
_visitorWrapper .getSchemas ().addSchema (type , _avroSchema );
0 commit comments