You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Bryan Duxbury (JIRA)" <ji...@apache.org> on 2009/07/14 03:44:14 UTC

[jira] Resolved: (THRIFT-543) Generate normal style java files should respect the "optional" keyword when serializing

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

Bryan Duxbury resolved THRIFT-543.
----------------------------------

       Resolution: Fixed
    Fix Version/s: 0.2
         Assignee: Chengdu Huang

I just committed this. Thanks for the patch, Chengdu!

> Generate normal style java files should respect the "optional" keyword when serializing 
> ----------------------------------------------------------------------------------------
>
>                 Key: THRIFT-543
>                 URL: https://issues.apache.org/jira/browse/THRIFT-543
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (Java)
>         Environment: all platforms
>            Reporter: Chengdu Huang
>            Assignee: Chengdu Huang
>             Fix For: 0.2
>
>         Attachments: thrift_java_optional_field.diff
>
>   Original Estimate: 0.08h
>  Remaining Estimate: 0.08h
>
> struct UserDataContent {
>    1: i32 id,
>    2: optional i32 value,
> }
> Java file generated by "thrift --gen java " doesn't seem to respect
> the "optional" keyword:
>  public void write(TProtocol oprot) throws TException {
>    validate();
>    oprot.writeStructBegin(STRUCT_DESC);
>    oprot.writeFieldBegin(ID_FIELD_DESC);
>    oprot.writeI32(this.id);
>    oprot.writeFieldEnd();
>    oprot.writeFieldBegin(VALUE_FIELD_DESC);
>    oprot.writeI32(this.value);
>    oprot.writeFieldEnd();
>    oprot.writeFieldStop();
>    oprot.writeStructEnd();
>  }
> However, java file generated using "thrift --gen java:beans" looks
> correct to me:
>  public void write(TProtocol oprot) throws TException {
>    validate();
>    oprot.writeStructBegin(STRUCT_DESC);
>    oprot.writeFieldBegin(ID_FIELD_DESC);
>    oprot.writeI32(this.id);
>    oprot.writeFieldEnd();
>    if (isSetValue()) {
>      oprot.writeFieldBegin(VALUE_FIELD_DESC);
>      oprot.writeI32(this.value);
>      oprot.writeFieldEnd();
>    }
>    oprot.writeFieldStop();
>    oprot.writeStructEnd();
>  }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.