[ https://issues.apache.org/jira/browse/THRIFT-3778?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jens Geyer updated THRIFT-3778: ------------------------------- Summary: go client can not pass method parameter to server of other language if no field_id is given (was: go client can not pass method parameter to server of other language) > go client can not pass method parameter to server of other language if no > field_id is given > ------------------------------------------------------------------------------------------- > > Key: THRIFT-3778 > URL: https://issues.apache.org/jira/browse/THRIFT-3778 > Project: Thrift > Issue Type: Bug > Components: Go - Compiler > Affects Versions: 0.9.3 > Reporter: Guo > > go client can not pass method parameter to java server > for example message.thrift > {code:title=message.thrift|borderStyle=solid} > namespace java test > namespace csharp test > namespace go test > struct Message > { > 1: string text > } > service MessageProcessor { > void process(Message message); > } > {code} > We generated messageprocess.go as golang client and MessageProcessor.java as > java server > When go client send service method arguments "process_args", 1 is sent as the > field_id of struct "message" > {code:title=messageprocessor.go|borderStyle=solid} > func (p *MessageProcessorProcessArgs) Write(oprot thrift.TProtocol) error { > if err := oprot.WriteStructBegin("process_args"); err != nil { > return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", > p), err) > } > if err := p.writeField_1(oprot); err != nil { > return err > } > ... > } > func (p *MessageProcessorProcessArgs) writeField_1(oprot thrift.TProtocol) > (err error) { > if err := oprot.WriteFieldBegin("message", thrift.STRUCT, 1); err != nil { > return thrift.PrependError(fmt.Sprintf("%T write field begin error > 1:message: ", p), err) > } > ... > } > {code} > When java server try to receive service method arguments "process_args", -1 > is marked as the field_id of struct "message" > {code:title=MessageProcessor.java|borderStyle=solid} > private static class process_argsStandardScheme extends > StandardScheme<process_args> { > ... > iprot.readStructBegin(); > while (true) > { > schemeField = iprot.readFieldBegin(); > if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { > break; > } > switch (schemeField.id) { > case -1: // MESSAGE > if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { > struct.message = new Message(); > struct.message.read(iprot); > struct.setMessageIsSet(true); > } else { > org.apache.thrift.protocol.TProtocolUtil.skip(iprot, > schemeField.type); > } > break; > default: > org.apache.thrift.protocol.TProtocolUtil.skip(iprot, > schemeField.type); > } > iprot.readFieldEnd(); > } > iprot.readStructEnd(); > ... > {code} > Because of this, we always receive NULL "message" in java server. > Compared to some other language implementation, I think it's a thrift go > generator problem. -- This message was sent by Atlassian JIRA (v6.3.4#6332)