diff --git a/avro/src/main/java/tools/jackson/dataformat/avro/schema/StringVisitor.java b/avro/src/main/java/tools/jackson/dataformat/avro/schema/StringVisitor.java index 8ad4b7a4..67bd54e5 100644 --- a/avro/src/main/java/tools/jackson/dataformat/avro/schema/StringVisitor.java +++ b/avro/src/main/java/tools/jackson/dataformat/avro/schema/StringVisitor.java @@ -11,7 +11,6 @@ import tools.jackson.databind.introspect.AnnotatedClass; import tools.jackson.databind.jsonFormatVisitors.JsonStringFormatVisitor; import tools.jackson.databind.jsonFormatVisitors.JsonValueFormat; -import tools.jackson.databind.type.TypeFactory; public class StringVisitor extends JsonStringFormatVisitor.Base implements SchemaBuilder @@ -38,7 +37,8 @@ public void enumTypes(Set enums) { public Schema builtAvroSchema() { // Unlike Jackson, Avro treats characters as an int with the java.lang.Character class type. if (_type.hasRawClass(char.class) || _type.hasRawClass(Character.class)) { - return AvroSchemaHelper.numericAvroSchema(NumberType.INT, TypeFactory.defaultInstance().constructType(Character.class)); + // should we construct JavaType for `Character.class` in case of primitive or... ? + return AvroSchemaHelper.numericAvroSchema(NumberType.INT, _type); } // [dataformats-binary#179]: need special help with UUIDs, to coerce into Binary // (could actually be diff --git a/avro/src/test/java/tools/jackson/dataformat/avro/schema/DateTimeVisitor_builtAvroSchemaTest.java b/avro/src/test/java/tools/jackson/dataformat/avro/schema/DateTimeVisitor_builtAvroSchemaTest.java index 6b187d85..983e367e 100644 --- a/avro/src/test/java/tools/jackson/dataformat/avro/schema/DateTimeVisitor_builtAvroSchemaTest.java +++ b/avro/src/test/java/tools/jackson/dataformat/avro/schema/DateTimeVisitor_builtAvroSchemaTest.java @@ -26,8 +26,6 @@ @RunWith(Parameterized.class) public class DateTimeVisitor_builtAvroSchemaTest { - private static final TypeFactory TYPE_FACTORY = TypeFactory.defaultInstance(); - @Parameter(0) public Class testClass; @@ -73,14 +71,16 @@ public static Collection testData() { LocalTime.class, JsonParser.NumberType.INT, Schema.Type.INT, - "time-millis"}, + "time-millis" + } }); } @Test public void builtAvroSchemaTest() { // GIVEN - DateTimeVisitor dateTimeVisitor = new DateTimeVisitor(TYPE_FACTORY.constructSimpleType(testClass, null)); + final TypeFactory tf = TypeFactory.createDefaultInstance(); + DateTimeVisitor dateTimeVisitor = new DateTimeVisitor(tf.constructSimpleType(testClass, null)); dateTimeVisitor.numberType(givenNumberType); // WHEN