diff --git a/release-notes/VERSION b/release-notes/VERSION index 0f6d553..faffb1d 100644 --- a/release-notes/VERSION +++ b/release-notes/VERSION @@ -4,6 +4,11 @@ Project: jackson-dataformat-avro = Releases ------------------------------------------------------------------------ +2.7.4 (not yet released) + +#39: Byte arrays are represented as strings in generated avro schema + (reported by asmaier@github) + 2.7.3 (16-Mar-2016) #35: Not able to serialize avro generated object having schema$ object diff --git a/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/VisitorFormatWrapperImpl.java b/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/VisitorFormatWrapperImpl.java index 6272f6b..de20843 100644 --- a/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/VisitorFormatWrapperImpl.java +++ b/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/VisitorFormatWrapperImpl.java @@ -91,6 +91,20 @@ public JsonMapFormatVisitor expectMapFormat(JavaType mapType) { @Override public JsonArrayFormatVisitor expectArrayFormat(JavaType convertedType) { + // 22-Mar-2016, tatu: Actually we can detect byte[] quite easily here can't we? + if (convertedType.isArrayType()) { + JavaType vt = convertedType.getContentType(); + if (vt.hasRawClass(Byte.TYPE)) { + _builder = new SchemaBuilder() { + @Override + public Schema builtAvroSchema() { + return Schema.create(Schema.Type.BYTES); + } + + }; + return null; + } + } ArrayVisitor v = new ArrayVisitor(_provider, convertedType, _schemas); _builder = v; return v; diff --git a/src/test/java/com/fasterxml/jackson/dataformat/avro/failing/BinaryDataTest.java b/src/test/java/com/fasterxml/jackson/dataformat/avro/failing/BinaryDataTest.java index 61cce54..d9f14e7 100644 --- a/src/test/java/com/fasterxml/jackson/dataformat/avro/failing/BinaryDataTest.java +++ b/src/test/java/com/fasterxml/jackson/dataformat/avro/failing/BinaryDataTest.java @@ -26,7 +26,7 @@ public void testAvroSchemaGenerationWithJackson() throws Exception byte[] ser = mapper.writer(schema).writeValueAsBytes(new FilePojo("ABC")); assertNotNull(ser); - + // plus should probably also read back, right? FilePojo result = mapper.readerFor(FilePojo.class) .with(schema)