From dev-return-53538-archive-asf-public=cust-asf.ponee.io@thrift.apache.org Fri Oct 12 15:59:09 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id EA86218076D for ; Fri, 12 Oct 2018 15:59:08 +0200 (CEST) Received: (qmail 64154 invoked by uid 500); 12 Oct 2018 13:59:07 -0000 Mailing-List: contact dev-help@thrift.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@thrift.apache.org Delivered-To: mailing list dev@thrift.apache.org Received: (qmail 64009 invoked by uid 99); 12 Oct 2018 13:59:07 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Oct 2018 13:59:07 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 638DCC7D9F for ; Fri, 12 Oct 2018 13:59:07 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -109.501 X-Spam-Level: X-Spam-Status: No, score=-109.501 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id B-gTms91893G for ; Fri, 12 Oct 2018 13:59:06 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 02A2360E40 for ; Fri, 12 Oct 2018 13:59:04 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id BECDEE2637 for ; Fri, 12 Oct 2018 13:59:02 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 9256C24E71 for ; Fri, 12 Oct 2018 13:59:01 +0000 (UTC) Date: Fri, 12 Oct 2018 13:59:01 +0000 (UTC) From: "Craig W (JIRA)" To: dev@thrift.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (THRIFT-4650) Required field incorrectly marked as set when fieldType does not match MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/THRIFT-4650?page=3Dcom.atlassi= an.jira.plugin.system.issuetabpanels:all-tabpanel ] Craig W updated THRIFT-4650: ---------------------------- Description:=20 The "Read" function that gets generated incorrectly marks required fields a= s being set when the type of the field does not match what's expected. {{For example, the following IDL:}} {{struct Foo {}} {{=C2=A0 1: required string id}} {{}}} {{The generated Read function has the following:}} {{switch fieldId {}} {{=C2=A0 case 1:}} {{=C2=A0=C2=A0=C2=A0 if fieldTypeId =3D=3D thrift.STRING {}} {{=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if err :=3D p.ReadField1(iprot); err !=3D= nil {}} {{=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return err}} =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } {{=C2=A0=C2=A0=C2=A0 } else {}} {{=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if err :=3D iprot.Skip(fieldTypeId); err = !=3D nil {}} {{=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return err}} =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } {{=C2=A0=C2=A0=C2=A0 issetID =3D true}} {{}}} {{I ran into a case where I attempted to deserialize another message type i= nto type Foo, and I expected it to return an error, but it did not.}} {{f : =3D Foo{}}} {{err :=3D thrift.NewTDeserializer().Read(&f, bytes)}} {{I think [this code|https://github.com/apache/thrift/blob/master/compiler/= cpp/src/thrift/generate/t_go_generator.cc#L1600] in the generator needs to = be moved inside the first "if" block, so that its only set to true if it ac= tually reads the data of the correct type.}} {{=C2=A0}} was: The "Read" function that gets generated incorrectly marks required fields a= s being set when the type of the field does not match what's expected. {{For example, the following IDL:}} {{struct Foo {}} {{=C2=A0 1: required string id}} {{}}} {{The generated Read function has the following:}} {{switch fieldId {}} {{=C2=A0 case 1:}} {{=C2=A0=C2=A0=C2=A0 if fieldTypeId =3D=3D thrift.STRING {}} {{=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if err :=3D p.ReadField1(iprot); err !=3D= nil {}} {{=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return err}} =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } {{=C2=A0=C2=A0=C2=A0 } else {}} {{=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if err :=3D iprot.Skip(fieldTypeId); err = !=3D nil {}} {{=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return err}} =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } {{=C2=A0=C2=A0=C2=A0 issetID =3D true}} {{}}} {{I ran into a case where I attempted to deserialize another message type i= nto type Foo, and I expected it to return an error, but it did not.}} {{f : =3D Foo}} {{err :=3D thrift.NewTDeserializer().Read(&f, bytes)}} {{I think [this code|https://github.com/apache/thrift/blob/master/compiler/= cpp/src/thrift/generate/t_go_generator.cc#L1600] in the generator needs to = be moved inside the first "if" block, so that its only set to true if it ac= tually reads the data of the correct type.}} {{=C2=A0}} > Required field incorrectly marked as set when fieldType does not match > ---------------------------------------------------------------------- > > Key: THRIFT-4650 > URL: https://issues.apache.org/jira/browse/THRIFT-4650 > Project: Thrift > Issue Type: Bug > Components: Go - Compiler > Affects Versions: 0.11.0 > Reporter: Craig W > Priority: Major > > The "Read" function that gets generated incorrectly marks required fields= as being set when the type of the field does not match what's expected. > {{For example, the following IDL:}} > {{struct Foo {}} > {{=C2=A0 1: required string id}} > {{}}} > {{The generated Read function has the following:}} > {{switch fieldId {}} > {{=C2=A0 case 1:}} > {{=C2=A0=C2=A0=C2=A0 if fieldTypeId =3D=3D thrift.STRING {}} > {{=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if err :=3D p.ReadField1(iprot); err != =3D nil {}} > {{=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return err}} > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = } > {{=C2=A0=C2=A0=C2=A0 } else {}} > {{=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if err :=3D iprot.Skip(fieldTypeId); er= r !=3D nil {}} > {{=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return err}} > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } > {{=C2=A0=C2=A0=C2=A0 issetID =3D true}} > {{}}} > {{I ran into a case where I attempted to deserialize another message type= into type Foo, and I expected it to return an error, but it did not.}} > {{f : =3D Foo{}}} > {{err :=3D thrift.NewTDeserializer().Read(&f, bytes)}} > {{I think [this code|https://github.com/apache/thrift/blob/master/compile= r/cpp/src/thrift/generate/t_go_generator.cc#L1600] in the generator needs t= o be moved inside the first "if" block, so that its only set to true if it = actually reads the data of the correct type.}} > {{=C2=A0}} -- This message was sent by Atlassian JIRA (v7.6.3#76005)