Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-2773

Generated Java code for 'oneway' methods is incorrect.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 0.9.3
    • None
    • Mac OS X

    Description

      While the ticket THRIFT-2704 (and associated pull request https://github.com/apache/thrift/pull/216) adds support to Java for 'oneway' service calls, the changes only apply to the generated AsyncClient.

      The synchronous client code calls TServiceClient.sendBase() which always generates a TMessage of type T_CALL.

      oneway-test.thrift
      service TestService {
          oneway void testFunction();
      }
      
      TestService.java
      public class TestService {
      ⋮
        public static class Client extends org.apache.thrift.TServiceClient implements Iface {
          ⋮
          public void send_testFunction() throws org.apache.thrift.TException
          {
            ⋮
            sendBase("testFunction", args); // note the lack of message type here
          }
        }
        ⋮
        public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface {
          ⋮
          public static class testFunction_call extends org.apache.thrift.async.TAsyncMethodCall {
            ⋮
            public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
              prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("testFunction", org.apache.thrift.protocol.TMessageType.ONEWAY, 0)); // ONEWAY is specified correctly
              testFunction_args args = new testFunction_args();
              args.write(prot);
              prot.writeMessageEnd();
            }
            ⋮
          }
        }
      ⋮
      }
      
      TServiceClient.java
      public abstract class TServiceClient {
      ⋮
        protected void sendBase(String methodName, TBase args) throws TException {
          oprot_.writeMessageBegin(new TMessage(methodName, TMessageType.CALL, ++seqid_)); // note hardcoded CALL
          ⋮
        }
      ⋮
      }
      

      Attachments

        Activity

          People

            hcorg Konrad Grochowski
            adamzegelin Adam Zegelin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: