You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2016/04/05 10:07:25 UTC
[jira] [Commented] (THRIFT-3778) go client can not pass method
parameter to server of other language
[ https://issues.apache.org/jira/browse/THRIFT-3778?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15225858#comment-15225858 ]
ASF GitHub Bot commented on THRIFT-3778:
----------------------------------------
GitHub user ggndnn opened a pull request:
https://github.com/apache/thrift/pull/978
THRIFT-3778 go client can not pass method parameter to server
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/ggndnn/thrift THRIFT-3778
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/thrift/pull/978.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #978
----
commit e3921fb22fe395470ce69ec7ae115822a7bf5e00
Author: guo <gg...@163.com>
Date: 2016-04-05T07:48:25Z
THRIFT-3778 go client can not pass method parameter to server of other language
----
> go client can not pass method parameter to server of other language
> -------------------------------------------------------------------
>
> 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)