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

Kevin Radloff commented on THRIFT-1699:
---------------------------------------

{code}
          // read field end
          default_read_field_end(protocol);
        
          field_header = default_read_field_begin(protocol);
          field_type_value = rb_ary_entry(field_header, 1);
          field_type = FIX2INT(field_type_value);
        
          if (field_type != TTYPE_STOP) {
            rb_raise(rb_eRuntimeError, "too many fields in union!");
          }
        
          // read field end
          default_read_field_end(protocol);
{code}

The code is calling default_read_field_end to look for the end of the first 
(which should also be the only field) in the union. It then calls 
default_read_field_begin to verify that there is not the start of another 
field. It then errantly calls default_read_field_end despite the fact the prior 
default_read_field_begin should not have consumed any further characters (or 
done anything else besides returned TTYPE_STOP). If you are counting the 
instances of read_field_begin and read_field_end, then yes, they match up right 
now, but this is a union and not a standard struct, and the behavior is unique 
here.

And unfortunately, I have not had much luck running the thrift ruby test suite. 
It appears as though this has gone undiscovered because there are no tests that 
use unions. And no users probably use unions, either. ;)
                
> Native Union#read has extra read_field_end call
> -----------------------------------------------
>
>                 Key: THRIFT-1699
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1699
>             Project: Thrift
>          Issue Type: Bug
>          Components: Ruby - Library
>    Affects Versions: 0.8
>            Reporter: Kevin Radloff
>         Attachments: struct.diff
>
>
> The native implementation of the Union#read method has an extraneous call to 
> read_field_end. This makes no difference to most protocols because 
> read_field_end is a no-op, but it breaks JSON (in this case my own class, not 
> the one in trunk), which does do something in this method.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to