You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Chengdu Huang (JIRA)" <ji...@apache.org> on 2009/07/14 03:22:14 UTC
[jira] Updated: (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 ]
Chengdu Huang updated THRIFT-543:
---------------------------------
Attachment: thrift_java_optional_field.diff
Respect the "optional" keyword in generated normal java style files.
> 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
> 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.