Return-Path: X-Original-To: apmail-avro-dev-archive@www.apache.org Delivered-To: apmail-avro-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 B43969FCF for ; Wed, 8 Feb 2012 21:37:25 +0000 (UTC) Received: (qmail 3013 invoked by uid 500); 8 Feb 2012 21:37:25 -0000 Delivered-To: apmail-avro-dev-archive@avro.apache.org Received: (qmail 2937 invoked by uid 500); 8 Feb 2012 21:37:24 -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 2929 invoked by uid 99); 8 Feb 2012 21:37:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Feb 2012 21:37:24 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Feb 2012 21:37:22 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 2595E1AAF93 for ; Wed, 8 Feb 2012 21:37:01 +0000 (UTC) Date: Wed, 8 Feb 2012 21:37:01 +0000 (UTC) From: "Scott Carey (Commented) (JIRA)" To: dev@avro.apache.org Message-ID: <1551493523.16740.1328737021155.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <311301420.76083.1327483001015.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (AVRO-1007) Insufficient validation in generated specific record builder implementations MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/AVRO-1007?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13204021#comment-13204021 ] Scott Carey commented on AVRO-1007: ----------------------------------- With this patch, the below tests are not consistent. IMO these should all pass, or all fail. No record has a default, so if any of these were missing during schema resolution it would fail. If we want the builder API to behave similar to schema resolution all should fail. If we want an unset field to behave as if it were set to null, then all should pass. {code} Schema rec = new Schema.Parser().parse("{\"type\":\"record\", \"name\":\"Nothing\", \"fields\":[" + "{\"name\":\"blank\", \"type\": \"null\"}]}"); Schema unionSchema = new Schema.Parser().parse("{\"type\":\"record\", \"name\":\"Person\", \"fields\":[" + "{\"name\":\"address\", \"type\": [\"null\", \"string\"]}]}"); Schema unionSchema2 = new Schema.Parser().parse("{\"type\":\"record\", \"name\":\"Person\", \"fields\":[" + "{\"name\":\"address\", \"type\": [\"string\",\"null\"]}]}"); @Test public void buildNoFieldSet() { new GenericRecordBuilder(rec).build(); } @Test public void buildNoFieldSetUnion() { new GenericRecordBuilder(unionSchema).build(); } @Test public void buildNoFieldSetUnion2() { new GenericRecordBuilder(unionSchema2).build(); } {code} > Insufficient validation in generated specific record builder implementations > ---------------------------------------------------------------------------- > > Key: AVRO-1007 > URL: https://issues.apache.org/jira/browse/AVRO-1007 > Project: Avro > Issue Type: Bug > Affects Versions: 1.6.1 > Reporter: James Baldassari > Assignee: James Baldassari > Labels: java > Fix For: 1.6.2 > > Attachments: AVRO-1007-v2.patch, AVRO-1007-v3.patch, AVRO-1007-v4.patch, AVRO-1007.patch, AVRO-1007.patch, AVRO-1007.patch > > > The are two main problems with the generated build() method in specific record builders: > * For non-primitive types, if there is no default value and the user does not set the value, build() will execute successfully without throwing an exception > ** Instead, an AvroRuntimeException should be thrown with an exception message indicating the name of the required field that was not set > * For primitive types, if there is no default value and the user does not set the value, an AvroRuntimeException is thrown with the 'cause' set to a NullPointerException, which is not very helpful > ** The NPE comes from attempting to set the primitive field to the result of defaultValue(), which is null -- 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