[
https://issues.apache.org/jira/browse/THRIFT-2420?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Frank Schroeder updated THRIFT-2420:
------------------------------------
Attachment: THRIFT-2420.patch
THRIFT-2420-with-indentation.patch
The THRIFT-2420.patch contains the output of {{git diff -b}} which shows the
changed code more clearly but then the t_go_generator.cc needs additional
indentation.
The THRIFT-2420-with-indentation.patch contains the output of {{git diff}}
which you should apply.
> Go argument parser for methods without arguments does not skip fields
> ---------------------------------------------------------------------
>
> Key: THRIFT-2420
> URL: https://issues.apache.org/jira/browse/THRIFT-2420
> Project: Thrift
> Issue Type: Bug
> Components: Go - Compiler
> Affects Versions: 0.9.2
> Environment: All
> Reporter: Frank Schroeder
> Fix For: 0.9.2
>
> Attachments: THRIFT-2420-with-indentation.patch, THRIFT-2420.patch
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> The Read() method of a struct of a thrift function which does not have
> arguments (e.g. foo()) calls iprot.ReadFieldBegin() to read the field type
> but does not consume/skip a field which it was not expecting.
> Read() methods for argument parsers for methods which have arguments have the
> correct code in the default section of the switch statement.
> This is the current code (I've added where the iprot.Skip() call is missing):
> {code}
> func (p *GetVersionDataArgs) Read(iprot thrift.TProtocol) error {
> if _, err := iprot.ReadStructBegin(); err != nil {
> return fmt.Errorf("%T read error: %s", p, err)
> }
> for {
> _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
> if err != nil {
> return fmt.Errorf("%T field %d read error: %s", p,
> fieldId, err)
> }
> if fieldTypeId == thrift.STOP {
> break
> }
> // should call iprot.Skip(fieldTypeId) if not STOP
> if err := iprot.ReadFieldEnd(); err != nil {
> return err
> }
> }
> if err := iprot.ReadStructEnd(); err != nil {
> return fmt.Errorf("%T read struct end error: %s", p, err)
> }
> return nil
> }
> {code}
> After the check for {{thrift.STOP}} there needs to be this code
> {code}
> if err := iprot.Skip(fieldTypeId); err != nil {
> return err
> }
> {code}
> We've found this because on the Java side we dynamically inject fields into
> the struct on call which are ignored on the Go side as long as the function
> has arguments. When we make a call to the no-argument function some bytes are
> not consumed and make the thrift code go out of sync.
> I will attach a patch which fixes this.
--
This message was sent by Atlassian JIRA
(v6.2#6252)