diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/StringVisitor.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/StringVisitor.java index 48116d1d..b8f3f514 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/StringVisitor.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/StringVisitor.java @@ -10,7 +10,6 @@ import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonStringFormatVisitor; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonValueFormat; -import com.fasterxml.jackson.databind.type.TypeFactory; public class StringVisitor extends JsonStringFormatVisitor.Base implements SchemaBuilder @@ -37,7 +36,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/com/fasterxml/jackson/dataformat/avro/schema/DateTimeVisitor_builtAvroSchemaTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/DateTimeVisitor_builtAvroSchemaTest.java index e724115b..90261f1c 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/DateTimeVisitor_builtAvroSchemaTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/DateTimeVisitor_builtAvroSchemaTest.java @@ -25,10 +25,8 @@ @RunWith(Parameterized.class) public class DateTimeVisitor_builtAvroSchemaTest { - private static final TypeFactory TYPE_FACTORY = TypeFactory.defaultInstance(); - @Parameter(0) - public Class testClass; + public Class testClass; @Parameter(1) public JsonParser.NumberType givenNumberType; @@ -40,7 +38,7 @@ public class DateTimeVisitor_builtAvroSchemaTest { public String expectedLogicalType; @Parameters(name = "With {0} and number type {1}") - public static Collection testData() { + public static Collection testData() { return Arrays.asList(new Object[][]{ // Java type | given number type, | expected Avro type | expected logicalType { @@ -72,14 +70,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