Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 2E931200B27 for ; Wed, 22 Jun 2016 18:32:01 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 2CDA2160A64; Wed, 22 Jun 2016 16:32:01 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 72F9D160A24 for ; Wed, 22 Jun 2016 18:32:00 +0200 (CEST) Received: (qmail 7758 invoked by uid 500); 22 Jun 2016 16:31:58 -0000 Mailing-List: contact dev-help@avro.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@avro.apache.org Delivered-To: mailing list dev@avro.apache.org Received: (qmail 7566 invoked by uid 99); 22 Jun 2016 16:31:58 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Jun 2016 16:31:58 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 34C962C1F71 for ; Wed, 22 Jun 2016 16:31:58 +0000 (UTC) Date: Wed, 22 Jun 2016 16:31:58 +0000 (UTC) From: "Ryan Blue (JIRA)" To: dev@avro.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (AVRO-1865) GenericData.Array class missing no arg constructor for Kryo serialization MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 22 Jun 2016 16:32:01 -0000 [ https://issues.apache.org/jira/browse/AVRO-1865?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15344683#comment-15344683 ] Ryan Blue commented on AVRO-1865: --------------------------------- The schema needs to be there, but for Kryo will be set during deserialization, not during construction. That's why we should have a comment on the schema-less constructor saying not to actually use it because it's for deserialization via Kryo or Java Serialization only. > GenericData.Array class missing no arg constructor for Kryo serialization > ------------------------------------------------------------------------- > > Key: AVRO-1865 > URL: https://issues.apache.org/jira/browse/AVRO-1865 > Project: Avro > Issue Type: Bug > Components: java > Affects Versions: 1.8.1 > Reporter: Alexander Kasper > Labels: newbie, patch > Attachments: add-no-arg-ctor-genericdata-array.diff > > > When trying to serialize Java classes generated by Avro that contain a field as follows: > {{array myclasses = []}} > serialization fails with the following error message > {{com.esotericsoftware.kryo.KryoException: Class cannot be created (missing no-arg constructor)}} > Minimum example to recreate this: > Avro IDL definition: > {code:java} > @namespace("com.adello") > protocol KryoTest { > record TestRecord { > array values = []; > } > } > {code} > This gets compiled using {{java -jar avro-tools-1.8.1.jar idl2schemata kryo.avdl .}} > Resulting Avro schema: > {code:javascript} > { > "type" : "record", > "name" : "TestRecord", > "namespace" : "com.adello", > "fields" : [ { > "name" : "values", > "type" : { > "type" : "array", > "items" : "int" > }, > "default" : [ ] > } ] > } > {code} > Generate Java class using {{java -jar avro-tools-1.8.1.jar compile schema TestRecord.avsc}} > Kryo serialization test code: > {code:java} > Kryo kryo = new Kryo(); > try { > Output output = new Output(new FileOutputStream("test.bin")); > TestRecord o = TestRecord.newBuilder().build(); > System.out.println("Before serialization: "); > System.out.println(o.toString()); > kryo.writeObject(output, o); > output.close(); > Input input = new Input(new FileInputStream("test.bin")); > TestRecord i = kryo.readObject(input, TestRecord.class); > input.close(); > System.out.println("After deserialization: "); > System.out.println(i.toString()); > System.out.println(Objects.deepEquals(o, i)); > } catch (FileNotFoundException e) { > e.printStackTrace(); > } > {code} > This is a common enough issue with Kryo that they have a dedicated section on their website on it: http://docs.datatorrent.com/troubleshooting/#application-throwing-following-kryo-exception > The attached patch adds a no args constructor for the inner class Array of GenericData with zero entries and a dummy schema. My personal tests for serialization with Kryo were successful when using it. Since I do not have complete insight into Avro I'd like to know if this could be a breaking change and how to test it if so. -- This message was sent by Atlassian JIRA (v6.3.4#6332)