You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "George Fletcher (JIRA)" <ji...@apache.org> on 2012/09/14 21:37:08 UTC
[jira] [Created] (AVRO-1166) IDL return type of map fails
in schema processing
George Fletcher created AVRO-1166:
-------------------------------------
Summary: IDL return type of map<record> fails in schema processing
Key: AVRO-1166
URL: https://issues.apache.org/jira/browse/AVRO-1166
Project: Avro
Issue Type: Bug
Components: java
Affects Versions: 1.7.1
Reporter: George Fletcher
An IDL construct such as ...
{code:title=Foo.idl}
protocol MyService {
record Bar {
int count;
string message;
}
map<Bar> getBars();
}
{code}
generates run-time errors because of this code in SpecificData.java
{code:title=SpecificData.java lines 189-196}
} 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));
} else {
{code}
the issue is that CharSequence.class.isAssignableFrom((Class)type)) should really be CharSequence.class.isAssignableFrom((Class)*key*))
--
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
[jira] [Resolved] (AVRO-1166) IDL return type of map fails
in schema processing
Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/AVRO-1166?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Doug Cutting resolved AVRO-1166.
--------------------------------
Resolution: Fixed
Fix Version/s: 1.7.2
Assignee: George Fletcher
I committed this. Thanks, George.
> IDL return type of map<record> fails in schema processing
> ---------------------------------------------------------
>
> Key: AVRO-1166
> URL: https://issues.apache.org/jira/browse/AVRO-1166
> Project: Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.7.1
> Reporter: George Fletcher
> Assignee: George Fletcher
> Fix For: 1.7.2
>
> Attachments: AVRO-1166.patch
>
>
> An IDL construct such as ...
> {code:title=Foo.idl}
> protocol MyService {
> record Bar {
> int count;
> string message;
> }
> map<Bar> getBars();
> }
> {code}
> generates run-time errors because of this code in SpecificData.java
> {code:title=SpecificData.java lines 189-196}
> } 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));
> } else {
> {code}
> the issue is that CharSequence.class.isAssignableFrom((Class)type)) should really be CharSequence.class.isAssignableFrom((Class)*key*))
--
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
[jira] [Commented] (AVRO-1166) IDL return type of map fails
in schema processing
Posted by "Amine R. (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/AVRO-1166?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13456165#comment-13456165 ]
Amine R. commented on AVRO-1166:
--------------------------------
Adding debug information when the {{org.apache.avro.AvroTypeException: Map key class not CharSequence: class java.lang.String}} gets thrown:
{code}
this = {org.apache.avro.specific.SpecificData@2754}
type = {sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl@2760}"java.util.Map<java.lang.String, com.foo.bar.MyObject>"
names = {java.util.LinkedHashMap@2761} size = 0
ptype = {sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl@2760}"java.util.Map<java.lang.String, com.foo.bar.MyObject>"
raw = {java.lang.Class@2762}"interface java.util.Map"
params = {java.lang.reflect.Type[2]@2763}
key = {java.lang.Class@2764}"class java.lang.String"
value = {java.lang.Class@2451}"class com.foo.bar.MyObject"
params[1] = {java.lang.Class@2451}"class com.foo.bar.MyObject"
{code}
> IDL return type of map<record> fails in schema processing
> ---------------------------------------------------------
>
> Key: AVRO-1166
> URL: https://issues.apache.org/jira/browse/AVRO-1166
> Project: Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.7.1
> Reporter: George Fletcher
>
> An IDL construct such as ...
> {code:title=Foo.idl}
> protocol MyService {
> record Bar {
> int count;
> string message;
> }
> map<Bar> getBars();
> }
> {code}
> generates run-time errors because of this code in SpecificData.java
> {code:title=SpecificData.java lines 189-196}
> } 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));
> } else {
> {code}
> the issue is that CharSequence.class.isAssignableFrom((Class)type)) should really be CharSequence.class.isAssignableFrom((Class)*key*))
--
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
[jira] [Commented] (AVRO-1166) IDL return type of map fails
in schema processing
Posted by "Amine R. (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/AVRO-1166?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13456168#comment-13456168 ]
Amine R. commented on AVRO-1166:
--------------------------------
SpecificData.getSchema(Bar.class) would not throw the error, but SpecificData.getSchema(Map<String, Bar>) will.
> IDL return type of map<record> fails in schema processing
> ---------------------------------------------------------
>
> Key: AVRO-1166
> URL: https://issues.apache.org/jira/browse/AVRO-1166
> Project: Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.7.1
> Reporter: George Fletcher
>
> An IDL construct such as ...
> {code:title=Foo.idl}
> protocol MyService {
> record Bar {
> int count;
> string message;
> }
> map<Bar> getBars();
> }
> {code}
> generates run-time errors because of this code in SpecificData.java
> {code:title=SpecificData.java lines 189-196}
> } 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));
> } else {
> {code}
> the issue is that CharSequence.class.isAssignableFrom((Class)type)) should really be CharSequence.class.isAssignableFrom((Class)*key*))
--
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
[jira] [Commented] (AVRO-1166) IDL return type of map fails
in schema processing
Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/AVRO-1166?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13456130#comment-13456130 ]
Doug Cutting commented on AVRO-1166:
------------------------------------
The bug looks real, but I don't see any code that calls this. For example, SpecificData.getSchema(Bar.class) works without error. Can you please provide a full stack trace, and/or some sample code that causes this to produce the wrong results? Thanks!
> IDL return type of map<record> fails in schema processing
> ---------------------------------------------------------
>
> Key: AVRO-1166
> URL: https://issues.apache.org/jira/browse/AVRO-1166
> Project: Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.7.1
> Reporter: George Fletcher
>
> An IDL construct such as ...
> {code:title=Foo.idl}
> protocol MyService {
> record Bar {
> int count;
> string message;
> }
> map<Bar> getBars();
> }
> {code}
> generates run-time errors because of this code in SpecificData.java
> {code:title=SpecificData.java lines 189-196}
> } 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));
> } else {
> {code}
> the issue is that CharSequence.class.isAssignableFrom((Class)type)) should really be CharSequence.class.isAssignableFrom((Class)*key*))
--
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
[jira] [Commented] (AVRO-1166) IDL return type of map fails
in schema processing
Posted by "Amine R. (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/AVRO-1166?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13456153#comment-13456153 ]
Amine R. commented on AVRO-1166:
--------------------------------
Hello Doug,
Thanks for getting back to us so quickly
java.lang.RuntimeException: org.apache.avro.AvroTypeException: Map key class not CharSequence: class java.lang.String
Caused by: org.apache.avro.AvroTypeException: Map key class not CharSequence: class java.lang.String
at org.apache.avro.specific.SpecificData.createSchema(SpecificData.java:180)
at org.apache.avro.specific.SpecificData.getSchema(SpecificData.java:140)
at com.foo.bar.encode.AvroEncoder.encode(AvroEncoder.java:44)
... 7 more
the encode method has this body :
{code}
public byte[] encode(Object object, Type type) throws IOException {
SpecificDatumWriter<Object> writer = new SpecificDatumWriter<Object>(SpecificData.get().getSchema(type));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonEncoder encoder = EncoderFactory.get().jsonEncoder(SpecificData.get().getSchema(type), baos);
writer.write(object, encoder);
encoder.flush();
return baos.toByteArray();
}
{code}
> IDL return type of map<record> fails in schema processing
> ---------------------------------------------------------
>
> Key: AVRO-1166
> URL: https://issues.apache.org/jira/browse/AVRO-1166
> Project: Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.7.1
> Reporter: George Fletcher
>
> An IDL construct such as ...
> {code:title=Foo.idl}
> protocol MyService {
> record Bar {
> int count;
> string message;
> }
> map<Bar> getBars();
> }
> {code}
> generates run-time errors because of this code in SpecificData.java
> {code:title=SpecificData.java lines 189-196}
> } 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));
> } else {
> {code}
> the issue is that CharSequence.class.isAssignableFrom((Class)type)) should really be CharSequence.class.isAssignableFrom((Class)*key*))
--
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
[jira] [Updated] (AVRO-1166) IDL return type of map fails
in schema processing
Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/AVRO-1166?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Doug Cutting updated AVRO-1166:
-------------------------------
Attachment: AVRO-1166.patch
Here's a patch to fix this that includes a test case.
Unless there are objections I'll commit this soon.
> IDL return type of map<record> fails in schema processing
> ---------------------------------------------------------
>
> Key: AVRO-1166
> URL: https://issues.apache.org/jira/browse/AVRO-1166
> Project: Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.7.1
> Reporter: George Fletcher
> Attachments: AVRO-1166.patch
>
>
> An IDL construct such as ...
> {code:title=Foo.idl}
> protocol MyService {
> record Bar {
> int count;
> string message;
> }
> map<Bar> getBars();
> }
> {code}
> generates run-time errors because of this code in SpecificData.java
> {code:title=SpecificData.java lines 189-196}
> } 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));
> } else {
> {code}
> the issue is that CharSequence.class.isAssignableFrom((Class)type)) should really be CharSequence.class.isAssignableFrom((Class)*key*))
--
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