avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thiruvalluvan M. G. (Updated) (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (AVRO-1066) ArrayIndexOutOfBoundsException in ParsingEncoder when trying to use a json encoder to serialize a deep object graph
Date Fri, 20 Apr 2012 12:04:40 GMT

     [ https://issues.apache.org/jira/browse/AVRO-1066?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Thiruvalluvan M. G. updated AVRO-1066:
--------------------------------------

        Fix Version/s: 1.7.0
             Assignee: Thiruvalluvan M. G.
    Affects Version/s:     (was: 1.6.2)
                       1.6.3
               Status: Patch Available  (was: Open)
    
> ArrayIndexOutOfBoundsException in ParsingEncoder when trying to use a json encoder to
serialize a deep object graph
> -------------------------------------------------------------------------------------------------------------------
>
>                 Key: AVRO-1066
>                 URL: https://issues.apache.org/jira/browse/AVRO-1066
>             Project: Avro
>          Issue Type: Bug
>    Affects Versions: 1.6.3
>            Reporter: Daniel Lord
>            Assignee: Thiruvalluvan M. G.
>             Fix For: 1.7.0
>
>         Attachments: AVRO-1066.patch
>
>
> I have an avro record that can have an array of children records of the same type.  If
this structure gets to be too deep then I continually get an ArrayOutOfBoundsException in
ParsingEncoder when trying to use a json encoder.  This works fine when using a binary encoder.
 My schema looks something like this: 
> {
>     "name" : "MyRecord",
>     "type" : "record",
>     "fields" : [
>         {
>             "name" : "fooField",
>             "type" : "int"
>         },
>         {
>             "name" : "childRecords",
>             "type" : [ "null", { "type" : "array", "items" : "MyRecord" } ]
>         }
>     ]
> }
> The code I'm using to capture a JSON string for debugging looks like this: 
>         ByteArrayOutputStream os = null;
>         try {
>             os = new ByteArrayOutputStream(2048);
>             final Encoder jsonEncoder = EncoderFactory.get().jsonEncoder(MyRecord.SCHEMA$,
os);
>             final DatumWriter<MyRecord> datumWriter = new SpecificDatumWriter<MyRecord>(MyRecord.class);
>             datumWriter.write(record, jsonEncoder);
>             jsonEncoder.flush();
>             return new String(os.toByteArray(), Charset.defaultCharset());
>         } catch (IOException e) {
>             return null;
>         } finally {
>             if (os != null) {
>                 try {
>                     os.close();
>                 } catch (IOException e) {
>                 }
>             }
>         }
> The error I get looks like this: 
> java.lang.ArrayIndexOutOfBoundsException: 10
> 	at org.apache.avro.io.ParsingEncoder.push(ParsingEncoder.java:55)
> 	at org.apache.avro.io.JsonEncoder.writeArrayStart(JsonEncoder.java:231)
> 	at org.apache.avro.generic.GenericDatumWriter.writeArray(GenericDatumWriter.java:125)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:67)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:72)
> 	at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:105)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:65)
> 	at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:105)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:65)
> 	at org.apache.avro.generic.GenericDatumWriter.writeArray(GenericDatumWriter.java:129)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:67)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:72)
> 	at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:105)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:65)
> 	at org.apache.avro.generic.GenericDatumWriter.writeArray(GenericDatumWriter.java:129)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:67)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:72)
> 	at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:105)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:65)
> 	at org.apache.avro.generic.GenericDatumWriter.writeArray(GenericDatumWriter.java:129)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:67)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:72)
> 	at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:105)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:65)
> 	at org.apache.avro.generic.GenericDatumWriter.writeArray(GenericDatumWriter.java:129)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:67)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:72)
> 	at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:105)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:65)
> 	at org.apache.avro.generic.GenericDatumWriter.writeArray(GenericDatumWriter.java:129)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:67)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:72)
> 	at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:105)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:65)
> 	at org.apache.avro.generic.GenericDatumWriter.writeArray(GenericDatumWriter.java:129)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:67)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:72)
> 	at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:105)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:65)
> 	at org.apache.avro.generic.GenericDatumWriter.writeArray(GenericDatumWriter.java:129)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:67)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:72)
> 	at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:105)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:65)
> 	at org.apache.avro.generic.GenericDatumWriter.writeArray(GenericDatumWriter.java:129)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:67)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:72)
> 	at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:105)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:65)
> 	at org.apache.avro.generic.GenericDatumWriter.writeArray(GenericDatumWriter.java:129)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:67)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:72)
> 	at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:105)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:65)
> 	at org.apache.avro.generic.GenericDatumWriter.writeArray(GenericDatumWriter.java:129)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:67)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:72)
> 	at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:105)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:65)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:57)
> <my line calling datumWriter.write> 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message