You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by hc...@apache.org on 2014/11/06 19:10:35 UTC

thrift git commit: THRIFT-2773: java - fixed oneway support while using TServiceClient

Repository: thrift
Updated Branches:
  refs/heads/master 4f4b15ba2 -> cc092b37c


THRIFT-2773: java - fixed oneway support while using TServiceClient

Client: java
Patch: Konrad Grochowski

new method for oneway call provided by TServiceClient
and compiler will now use it

This closes #241


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/cc092b37
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/cc092b37
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/cc092b37

Branch: refs/heads/master
Commit: cc092b37c8665384f2f7cb60d184a44f59ac3ba3
Parents: 4f4b15b
Author: Konrad Grochowski <hc...@apache.org>
Authored: Wed Oct 8 11:52:00 2014 +0200
Committer: Konrad Grochowski <hc...@apache.org>
Committed: Wed Nov 5 19:00:54 2014 +0100

----------------------------------------------------------------------
 compiler/cpp/src/generate/t_java_generator.cc      |  3 ++-
 lib/java/src/org/apache/thrift/TServiceClient.java | 14 +++++++++++---
 2 files changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/cc092b37/compiler/cpp/src/generate/t_java_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_java_generator.cc b/compiler/cpp/src/generate/t_java_generator.cc
index e22a4d9..4e2046f 100644
--- a/compiler/cpp/src/generate/t_java_generator.cc
+++ b/compiler/cpp/src/generate/t_java_generator.cc
@@ -2674,7 +2674,8 @@ void t_java_generator::generate_service_client(t_service* tservice) {
       indent(f_service_) << "args.set" << get_cap_name((*fld_iter)->get_name()) << "(" << (*fld_iter)->get_name() << ");" << endl;
     }
 
-    indent(f_service_) << "sendBase(\"" << funname << "\", args);" << endl;
+    const string sendBaseName = (*f_iter)->is_oneway() ? "sendBaseOneway" : "sendBase";
+    indent(f_service_) << sendBaseName << "(\"" << funname << "\", args);" << endl;
 
     scope_down(f_service_);
     f_service_ << endl;

http://git-wip-us.apache.org/repos/asf/thrift/blob/cc092b37/lib/java/src/org/apache/thrift/TServiceClient.java
----------------------------------------------------------------------
diff --git a/lib/java/src/org/apache/thrift/TServiceClient.java b/lib/java/src/org/apache/thrift/TServiceClient.java
index 15715f1..259a507 100644
--- a/lib/java/src/org/apache/thrift/TServiceClient.java
+++ b/lib/java/src/org/apache/thrift/TServiceClient.java
@@ -58,14 +58,22 @@ public abstract class TServiceClient {
     return this.oprot_;
   }
 
-  protected void sendBase(String methodName, TBase args) throws TException {
-    oprot_.writeMessageBegin(new TMessage(methodName, TMessageType.CALL, ++seqid_));
+  protected void sendBase(String methodName, TBase<?,?> args) throws TException {
+    sendBase(methodName, args, TMessageType.CALL);
+  }
+
+  protected void sendBaseOneway(String methodName, TBase<?,?> args) throws TException {
+    sendBase(methodName, args, TMessageType.ONEWAY);
+  }
+
+  private void sendBase(String methodName, TBase<?,?> args, byte type) throws TException {
+    oprot_.writeMessageBegin(new TMessage(methodName, type, ++seqid_));
     args.write(oprot_);
     oprot_.writeMessageEnd();
     oprot_.getTransport().flush();
   }
 
-  protected void receiveBase(TBase result, String methodName) throws TException {
+  protected void receiveBase(TBase<?,?> result, String methodName) throws TException {
     TMessage msg = iprot_.readMessageBegin();
     if (msg.type == TMessageType.EXCEPTION) {
       TApplicationException x = TApplicationException.read(iprot_);