Skip to content

Commit ba4ef84

Browse files
committed
Merge branch '2.x' into 3.x
2 parents d634145 + 60b2dab commit ba4ef84

File tree

7 files changed

+7
-32
lines changed

7 files changed

+7
-32
lines changed

avro/src/main/java/tools/jackson/dataformat/avro/schema/RecordVisitor.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,9 @@ public class RecordVisitor
6767
*/
6868
private final Schema _typeSchema;
6969

70-
// !!! 19-May-2025: TODO: make final in 2.20
71-
protected Schema _avroSchema;
70+
protected final Schema _avroSchema;
7271

73-
// !!! 19-May-2025: TODO: make final in 2.20
74-
protected List<Schema.Field> _fields = new ArrayList<>();
72+
protected final List<Schema.Field> _fields = new ArrayList<>();
7573

7674
public RecordVisitor(SerializationContext ctxt, JavaType type,
7775
VisitorFormatWrapperImpl visitorWrapper)
@@ -100,12 +98,11 @@ public RecordVisitor(SerializationContext ctxt, JavaType type,
10098
_typeSchema = null;
10199
} else {
102100
// If Avro schema for this _type results in UNION I want to know Avro type where to assign fields
103-
_avroSchema = AvroSchemaHelper.initializeRecordSchema(ctxt.getConfig(), _type, annotations);
104-
_typeSchema = _avroSchema;
101+
_typeSchema = AvroSchemaHelper.initializeRecordSchema(ctxt.getConfig(), _type, annotations);
105102
_overridden = false;
106103
AvroMeta meta = annotations.getAnnotation(AvroMeta.class);
107104
if (meta != null) {
108-
_avroSchema.addProp(meta.key(), meta.value());
105+
_typeSchema.addProp(meta.key(), meta.value());
109106
}
110107

111108
List<NamedType> subTypes = intr.findSubtypes(config, annotations);
@@ -144,6 +141,8 @@ public RecordVisitor(SerializationContext ctxt, JavaType type,
144141
}
145142
}
146143
_avroSchema = Schema.createUnion(new ArrayList<>(unionSchemas));
144+
} else {
145+
_avroSchema = _typeSchema;
147146
}
148147
}
149148
_visitorWrapper.getSchemas().addSchema(type, _avroSchema);

avro/src/test/java/tools/jackson/dataformat/avro/BigDecimal_schemaCreationTest.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ public void testSchemaCreation_withLogicalTypesDisabled_onBigDecimalWithAvroDeci
4242
// because logical types are disabled by default.
4343
final Schema actualSchema = gen.getGeneratedSchema().getAvroSchema();
4444

45-
//System.out.println(BigDecimalWithAvroDecimalAnnotationWrapper.class.getSimpleName() + " schema:" + actualSchema.toString(true));
46-
4745
// THEN
4846
assertThat(actualSchema.getField("bigDecimalValue")).isNotNull();
4947
Schema bigDecimalValue = actualSchema.getField("bigDecimalValue").schema();
@@ -64,8 +62,6 @@ public void testSchemaCreation_withLogicalTypesEnabled_onBigDecimalWithAvroDecim
6462
MAPPER.acceptJsonFormatVisitor(BigDecimalWithAvroDecimalAnnotationWrapper.class, gen);
6563
final Schema actualSchema = gen.getGeneratedSchema().getAvroSchema();
6664

67-
//System.out.println(BigDecimalWithAvroDecimalAnnotationWrapper.class.getSimpleName() + " schema:" + actualSchema.toString(true));
68-
6965
// THEN
7066
assertThat(actualSchema.getField("bigDecimalValue")).isNotNull();
7167
Schema bigDecimalValue = actualSchema.getField("bigDecimalValue").schema();
@@ -97,8 +93,6 @@ public void testSchemaCreation_withLogicalTypesEnabled_onBigDecimalWithAvroDecim
9793
MAPPER.acceptJsonFormatVisitor(BigDecimalWithAvroDecimalAnnotationToFixedWrapper.class, gen);
9894
final Schema actualSchema = gen.getGeneratedSchema().getAvroSchema();
9995

100-
//System.out.println(BigDecimalWithAvroDecimalAnnotationToFixedWrapper.class.getSimpleName() + " schema:" + actualSchema.toString(true));
101-
10296
// THEN
10397
assertThat(actualSchema.getField("bigDecimalValue")).isNotNull();
10498

avro/src/test/java/tools/jackson/dataformat/avro/jsr310/AvroJavaTimeModule_schemaCreationTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ public void testSchemaCreation(Class<?> testClass,
4646
mapper.acceptJsonFormatVisitor(testClass, gen);
4747
Schema actualSchema = gen.getGeneratedSchema().getAvroSchema();
4848

49-
// System.out.println(testClass.getName() + " schema:\n" + actualSchema.toString(true));
50-
5149
// THEN
5250
assertThat(actualSchema.getType()).isEqualTo(expectedType);
5351
assertThat(actualSchema.getProp(LogicalType.LOGICAL_TYPE_PROP)).isEqualTo(expectedLogicalType);

avro/src/test/java/tools/jackson/dataformat/avro/schema/DateTimeVisitor_builtAvroSchemaTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ public void builtAvroSchemaTest(Class<?> testClass,
6868
// WHEN
6969
Schema actualSchema = dateTimeVisitor.builtAvroSchema();
7070

71-
// System.out.println(testClass.getName() + " schema:\n" + actualSchema.toString(true));
72-
7371
// THEN
7472
assertThat(actualSchema.getType()).isEqualTo(expectedAvroType);
7573
assertThat(actualSchema.getProp(LogicalType.LOGICAL_TYPE_PROP)).isEqualTo(expectedLogicalType);

avro/src/test/java/tools/jackson/dataformat/avro/schema/Enum_schemaCreationTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ public void testJavaEnumToAvroEnum_test() throws Exception {
2626
MAPPER.acceptJsonFormatVisitor(NumbersEnum.class , gen);
2727
Schema actualSchema = gen.getGeneratedSchema().getAvroSchema();
2828

29-
//System.out.println("schema:\n" + actualSchema.toString(true));
30-
3129
// THEN
3230
assertThat(actualSchema.getType()).isEqualTo( Schema.Type.ENUM);
3331
assertThat(actualSchema.getEnumSymbols()).containsExactlyInAnyOrder("ONE", "TWO", "THREE");
@@ -43,8 +41,6 @@ public void testJavaEnumToAvroString_test() throws Exception {
4341
MAPPER.acceptJsonFormatVisitor(NumbersEnum.class , gen);
4442
Schema actualSchema = gen.getGeneratedSchema().getAvroSchema();
4543

46-
//System.out.println("schema:\n" + actualSchema.toString(true));
47-
4844
// THEN
4945
assertThat(actualSchema.getType()).isEqualTo( Schema.Type.STRING);
5046

avro/src/test/java/tools/jackson/dataformat/avro/schema/PolymorphicTypeAnnotationsTest.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ public void subclasses_of_interface_test() throws Exception {
4545
// WHEN
4646
Schema actualSchema = MAPPER.schemaFor(AnimalInterface.class).getAvroSchema();
4747

48-
// System.out.println("Animal schema:\n" + actualSchema.toString(true));
49-
5048
// THEN
5149
assertThat(actualSchema.getType()).isEqualTo(Schema.Type.UNION);
5250
// Because AnimalInterface is interface and AbstractMammal is abstract, they are not expected to be among types in union
@@ -82,8 +80,6 @@ public void jsonSubTypes_on_concrete_class_test() throws Exception {
8280
// WHEN
8381
Schema actualSchema = MAPPER.schemaFor(Fruit.class).getAvroSchema();
8482

85-
// System.out.println("Fruit schema:\n" + actualSchema.toString(true));
86-
8783
// THEN
8884
assertThat(actualSchema.getType()).isEqualTo(Schema.Type.UNION);
8985
assertThat(actualSchema.getTypes()).containsExactlyInAnyOrder(fruitItselfSchema, appleSchema, pearSchema);
@@ -142,8 +138,6 @@ public void jsonSubTypes_of_jsonSubTypes_test() throws Exception {
142138
// WHEN
143139
Schema actualSchema = MAPPER.schemaFor(Vehicle.class).getAvroSchema();
144140

145-
// System.out.println("Vehicle schema:\n" + actualSchema.toString(true));
146-
147141
// THEN
148142
assertThat(actualSchema.getType()).isEqualTo(Schema.Type.UNION);
149143
assertThat(actualSchema.getTypes()).containsExactlyInAnyOrder(
@@ -187,8 +181,6 @@ public void class_is_referenced_twice_in_hierarchy_test() throws Exception {
187181
// WHEN
188182
Schema actualSchema = MAPPER.schemaFor(ElementInterface.class).getAvroSchema();
189183

190-
// System.out.println("ElementInterface schema:\n" + actualSchema.toString(true));
191-
192184
// THEN
193185
assertThat(actualSchema.getType()).isEqualTo(Schema.Type.UNION);
194186
// ElementInterface and AbstractGas are not concrete classes they are not expected to be among types in union
@@ -223,8 +215,6 @@ public void base_class_explicitly_in_JsonSubTypes_annotation_test() throws Excep
223215
// WHEN
224216
Schema actualSchema = MAPPER.schemaFor(Image.class).getAvroSchema();
225217

226-
// System.out.println("Image schema:\n" + actualSchema.toString(true));
227-
228218
// THEN
229219
assertThat(actualSchema.getType()).isEqualTo(Schema.Type.UNION);
230220
assertThat(actualSchema.getTypes()).containsExactlyInAnyOrder(imageItselfSchema, jpegSchema, pngSchema);

release-notes/VERSION-2.x

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Active maintainers:
2828
- Fixes wrt [core#1438] (ParserBase.close() not resetting current token)
2929
- Generate SBOMs [JSTEP-14]
3030

31-
2.19.1 (not yet released)
31+
2.19.1 (13-Jun-2025)
3232

3333
#589: AvroSchema: Does not include base class for records with subclasses
3434
(reported by Rafael W)

0 commit comments

Comments
 (0)