[ 
https://issues.apache.org/jira/browse/THRIFT-452?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12698414#action_12698414
 ] 

Ben Maurer commented on THRIFT-452:
-----------------------------------

Writes seem to be done unconditionally:

{code}
enum A {
  X=1
}

struct B {
  1: A foo;
}
{code}

{code}
  public void write(TProtocol oprot) throws TException {
    validate();

    oprot.writeStructBegin(STRUCT_DESC);
    oprot.writeFieldBegin(FOO_FIELD_DESC);
    oprot.writeI32(this.foo);
    oprot.writeFieldEnd();
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }
{code}

> Gotcha with Java enums not having a zero value
> ----------------------------------------------
>
>                 Key: THRIFT-452
>                 URL: https://issues.apache.org/jira/browse/THRIFT-452
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (Java)
>            Reporter: Ben Maurer
>
> In the java library, if you define an enum that does not have a value 
> declared for 0, it seems like you can get into a strange situation. In java, 
> the field for the enum will be set to zero, but isset will be true. Compare 
> to a language like Python where the value will be None, causing isset to 
> effectively be false. When the value is deserialized, Java will check if the 
> enum value is valid, find that it is not, and throw an exception.
> Any thoughts on the best behavior?

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

Reply via email to