Skip to content
This repository has been archived by the owner on Jan 22, 2019. It is now read-only.

Commit

Permalink
Fix #39
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Mar 23, 2016
1 parent 09ad80f commit 7775c4a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7775c4a

Please sign in to comment.