44import java .util .List ;
55import java .util .Map ;
66
7- import com .fasterxml .jackson .dataformat .avro .annotation .Decimal ;
87import org .apache .avro .LogicalTypes ;
98import org .apache .avro .Schema ;
109import org .apache .avro .Schema .Type ;
1716import com .fasterxml .jackson .databind .jsontype .NamedType ;
1817import com .fasterxml .jackson .databind .ser .BeanPropertyWriter ;
1918import com .fasterxml .jackson .dataformat .avro .AvroFixedSize ;
19+ import com .fasterxml .jackson .dataformat .avro .annotation .Decimal ;
2020import com .fasterxml .jackson .dataformat .avro .ser .CustomEncodingSerializer ;
2121
2222public class RecordVisitor
@@ -150,17 +150,19 @@ protected Schema.Field schemaFieldForWriter(BeanProperty prop, boolean optional)
150150 Schema .Parser parser = new Schema .Parser ();
151151 writerSchema = parser .parse (schemaOverride .value ());
152152 } else {
153- if ( prop .getAnnotation (AvroFixedSize .class ) != null ) {
154- AvroFixedSize fixedSize = prop . getAnnotation ( AvroFixedSize . class );
153+ AvroFixedSize fixedSize = prop .getAnnotation (AvroFixedSize .class );
154+ if ( fixedSize != null ) {
155155 writerSchema = Schema .createFixed (fixedSize .typeName (), null , fixedSize .typeNamespace (), fixedSize .size ());
156156 }
157- if (_visitorWrapper .isLogicalTypesEnabled () && prop .getAnnotation (Decimal .class ) != null ) {
158- if (writerSchema == null ) {
159- writerSchema = Schema .create (Type .BYTES );
160- }
157+ if (_visitorWrapper .isLogicalTypesEnabled ()) {
161158 Decimal decimal = prop .getAnnotation (Decimal .class );
162- writerSchema = LogicalTypes .decimal (decimal .precision (), decimal .scale ())
163- .addToSchema (writerSchema );
159+ if (decimal != null ) {
160+ if (writerSchema == null ) {
161+ writerSchema = Schema .create (Type .BYTES );
162+ }
163+ writerSchema = LogicalTypes .decimal (decimal .precision (), decimal .scale ())
164+ .addToSchema (writerSchema );
165+ }
164166 }
165167 if (writerSchema == null ) {
166168 JsonSerializer <?> ser = null ;
@@ -169,9 +171,7 @@ protected Schema.Field schemaFieldForWriter(BeanProperty prop, boolean optional)
169171 if (prop instanceof BeanPropertyWriter ) {
170172 BeanPropertyWriter bpw = (BeanPropertyWriter ) prop ;
171173 ser = bpw .getSerializer ();
172- /*
173- * 2-Mar-2017, bryan: AvroEncode annotation expects to have the schema used directly
174- */
174+ // 2-Mar-2017, bryan: AvroEncode annotation expects to have the schema used directly
175175 optional = optional && !(ser instanceof CustomEncodingSerializer ); // Don't modify schema
176176 }
177177 final SerializerProvider prov = getProvider ();
0 commit comments