Return-Path: X-Original-To: apmail-crunch-dev-archive@www.apache.org Delivered-To: apmail-crunch-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2623F180F5 for ; Thu, 23 Jul 2015 17:05:05 +0000 (UTC) Received: (qmail 44942 invoked by uid 500); 23 Jul 2015 17:05:05 -0000 Delivered-To: apmail-crunch-dev-archive@crunch.apache.org Received: (qmail 44902 invoked by uid 500); 23 Jul 2015 17:05:05 -0000 Mailing-List: contact dev-help@crunch.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@crunch.apache.org Delivered-To: mailing list dev@crunch.apache.org Received: (qmail 44887 invoked by uid 500); 23 Jul 2015 17:05:05 -0000 Delivered-To: apmail-incubator-crunch-dev@incubator.apache.org Received: (qmail 44883 invoked by uid 99); 23 Jul 2015 17:05:05 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Jul 2015 17:05:05 +0000 Date: Thu, 23 Jul 2015 17:05:04 +0000 (UTC) From: "Josh Wills (JIRA)" To: crunch-dev@incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (CRUNCH-548) getDetachedValue calls to AvroReflectDeepCopier throw InstantiationException on non-concrete types MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CRUNCH-548?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Josh Wills updated CRUNCH-548: ------------------------------ Attachment: CRUNCH-548b.patch Version that removes the valueClass from the reflect deep copier. Committing now-ish. > getDetachedValue calls to AvroReflectDeepCopier throw InstantiationException on non-concrete types > -------------------------------------------------------------------------------------------------- > > Key: CRUNCH-548 > URL: https://issues.apache.org/jira/browse/CRUNCH-548 > Project: Crunch > Issue Type: Bug > Reporter: Adric Eckstein > Fix For: 0.13.0 > > Attachments: CRUNCH-548.patch, CRUNCH-548b.patch > > > A common use case with avro reflection is to operate on an abstract class or interface which is serialized using a schema based on a concrete subclass (or union of subclasses). > @org.apache.avro.reflect.Union({ Foo1.class }) > public interface Foo { > public String getFoo(); > } > public class Foo1 implements Foo { > private final Double value = 1.0; > @Override > public String getFoo() { > return value.toString(); > } > } > When trying to operate on this type within crunch, calls to getDetachedValue() will throw an InstantiationException: > AvroType ptype = Avros.reflects(Foo.class, ReflectData.get().getSchema(Foo.class)); > ptype.initialize(new Configuration()); > Foo copy1 = ptype.getDetachedValue(new Foo1()); > Exception in thread "main" org.apache.crunch.CrunchRuntimeException: java.lang.InstantiationException: org.mitre.caasd.tt.DeepCopyTest$Foo > at org.apache.crunch.types.avro.AvroDeepCopier$AvroReflectDeepCopier.createNewInstance(AvroDeepCopier.java:158) > One solution would be to augment the createNewInstance() method in AvroReflectDeepCopier to create a new instance based on the source object class, rather than the type class. This would generally be desirable for any union cases where the source is a subclass of the type class. -- This message was sent by Atlassian JIRA (v6.3.4#6332)