Skip to content

Commit f4e14dd

Browse files
abielewiczfmbenhassine
authored andcommitted
Change the order in which datum writer is selected
Due to GenericRecord being checked before SpecificRecordBase, GenericDatumWriter was used incorrectly for types that extend SpecificRecordBase. Resolves #3859
1 parent 4af4b05 commit f4e14dd

File tree

1 file changed

+4
-6
lines changed
  • spring-batch-infrastructure/src/main/java/org/springframework/batch/item/avro

1 file changed

+4
-6
lines changed

spring-batch-infrastructure/src/main/java/org/springframework/batch/item/avro/AvroItemWriter.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019 the original author or authors.
2+
* Copyright 2019-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -155,14 +155,12 @@ private void initializeWriter() throws IOException {
155155
}
156156

157157
private static <T> DatumWriter<T> datumWriterForClass(Class<T> clazz) {
158-
if (GenericRecord.class.isAssignableFrom(clazz)) {
159-
return new GenericDatumWriter<>();
160-
161-
}
162158
if (SpecificRecordBase.class.isAssignableFrom(clazz)){
163159
return new SpecificDatumWriter<>(clazz);
164160
}
165-
161+
if (GenericRecord.class.isAssignableFrom(clazz)) {
162+
return new GenericDatumWriter<>();
163+
}
166164
return new ReflectDatumWriter<>(clazz);
167165
}
168166

0 commit comments

Comments
 (0)