You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Ted Malaska (JIRA)" <ji...@apache.org> on 2013/02/12 18:35:12 UTC
[jira] [Commented] (AVRO-1148) SpecificData.java has a bug creating
a schema for a map
[ https://issues.apache.org/jira/browse/AVRO-1148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13576808#comment-13576808 ]
Ted Malaska commented on AVRO-1148:
-----------------------------------
Just looked at the code in the trunk and looks like this JIRA has been addressed.
Here is code that I just pulled from trunk.
else if (Map.class.isAssignableFrom(raw)) { // map
java.lang.reflect.Type key = params[0];
java.lang.reflect.Type value = params[1];
if (!(key instanceof Class
&& CharSequence.class.isAssignableFrom((Class)key)))
throw new AvroTypeException("Map key class not CharSequence: "+key);
return Schema.createMap(createSchema(value, names));
}
> SpecificData.java has a bug creating a schema for a map
> -------------------------------------------------------
>
> Key: AVRO-1148
> URL: https://issues.apache.org/jira/browse/AVRO-1148
> Project: Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.6.3
> Environment: Mac
> Reporter: Amine R.
> Labels: patch
>
> in the SepcificData class, the protected Schema createSchema(java.lang.reflect.Type type, Map<String,Schema> names) fails in creating a schema for the Map type.
> Looking at this excerpt,
> else if (Map.class.isAssignableFrom(raw)) { // map
> java.lang.reflect.Type key = params[0];
> java.lang.reflect.Type value = params[1];
> if (!(type instanceof Class
> && CharSequence.class.isAssignableFrom((Class)type)))
> throw new AvroTypeException("Map key class not CharSequence: "+key);
> return Schema.createMap(createSchema(value, names));
> }
> The type is a map, the key is a string. therefore instead of "if (!(type instanceof Class" it should be "if (!(key instanceof Class".
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira