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

Commit

Permalink
Backport #8 fix in 2.3.4 as well as it's easy, safe to do.
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jun 12, 2014
1 parent 4ae4bb6 commit 5e24f27
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Project: jackson-dataformat-avro
Version: 2.3.4 (xx-xxx-2014)

#8: Error in creating Avro Schema for `java.util.Date` (and related) type.

------------------------------------------------------------------------
=== History: ===
------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,14 @@ protected Schema schemaForWriter(BeanProperty prop)
BeanPropertyWriter bpw = (BeanPropertyWriter) prop;
ser = bpw.getSerializer();
}
final SerializerProvider prov = getProvider();
if (ser == null) {
SerializerProvider prov = getProvider();
if (prov == null) throw new Error();
ser = prov.findValueSerializer(prop.getType(), prop);
}
VisitorFormatWrapperImpl visitor = new VisitorFormatWrapperImpl(_schemas);
// Fix #8:
visitor.setProvider(prov);
ser.acceptJsonFormatVisitor(visitor, prop.getType());
return visitor.getAvroSchema();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ public static class RootType

@SuppressWarnings("serial")
public static class StringMap extends HashMap<String,String> { }

static class WithDate {
public Date date;
}

/*
/**********************************************************
Expand Down Expand Up @@ -92,4 +96,14 @@ public void testMap() throws Exception

// System.out.println("Map schema:\n"+json);
}

// [Issue#8]
public void testWithDate() throws Exception
{
ObjectMapper mapper = new ObjectMapper(new AvroFactory());
AvroSchemaGenerator gen = new AvroSchemaGenerator();
mapper.acceptJsonFormatVisitor(WithDate.class, gen);
AvroSchema schema = gen.getGeneratedSchema();
assertNotNull(schema);
}
}

0 comments on commit 5e24f27

Please sign in to comment.