THRIFT-818. java: Async client doesn't send method args
This patch amends the tests and fixes the bug.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@963901 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/java/src/org/apache/thrift/async/TAsyncClientManager.java b/lib/java/src/org/apache/thrift/async/TAsyncClientManager.java
index 8636bc8..b659f7c 100644
--- a/lib/java/src/org/apache/thrift/async/TAsyncClientManager.java
+++ b/lib/java/src/org/apache/thrift/async/TAsyncClientManager.java
@@ -25,6 +25,7 @@
import java.util.Iterator;
import java.util.concurrent.ConcurrentLinkedQueue;
+import org.apache.thrift.TException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -42,7 +43,8 @@
selectThread.start();
}
- public void call(TAsyncMethodCall method) {
+ public void call(TAsyncMethodCall method) throws TException {
+ method.prepareMethodCall();
pendingCalls.add(method);
selectThread.getSelector().wakeup();
}
diff --git a/lib/java/src/org/apache/thrift/async/TAsyncMethodCall.java b/lib/java/src/org/apache/thrift/async/TAsyncMethodCall.java
index e130087..7273b5b 100644
--- a/lib/java/src/org/apache/thrift/async/TAsyncMethodCall.java
+++ b/lib/java/src/org/apache/thrift/async/TAsyncMethodCall.java
@@ -62,7 +62,7 @@
private ByteBuffer frameBuffer;
private State state;
- protected TAsyncMethodCall(TAsyncClient client, TProtocolFactory protocolFactory, TNonblockingTransport transport, AsyncMethodCallback<T> callback, boolean isOneway) throws TException {
+ protected TAsyncMethodCall(TAsyncClient client, TProtocolFactory protocolFactory, TNonblockingTransport transport, AsyncMethodCallback<T> callback, boolean isOneway) {
this.transport = transport;
this.callback = callback;
this.protocolFactory = protocolFactory;
@@ -70,7 +70,6 @@
this.isOneway = isOneway;
this.state = State.WRITING_REQUEST_SIZE;
- prepareMethodCall();
}
protected State getState() {
@@ -79,7 +78,7 @@
protected abstract void write_args(TProtocol protocol) throws TException;
- private void prepareMethodCall() throws TException {
+ protected void prepareMethodCall() throws TException {
TMemoryBuffer memoryBuffer = new TMemoryBuffer(INITIAL_MEMORY_BUFFER_SIZE);
TProtocol protocol = protocolFactory.getProtocol(memoryBuffer);
write_args(protocol);
diff --git a/lib/java/test/org/apache/thrift/async/TestTAsyncClientManager.java b/lib/java/test/org/apache/thrift/async/TestTAsyncClientManager.java
index 5c8ff76..2962897 100644
--- a/lib/java/test/org/apache/thrift/async/TestTAsyncClientManager.java
+++ b/lib/java/test/org/apache/thrift/async/TestTAsyncClientManager.java
@@ -47,7 +47,8 @@
public class SrvHandler implements Iface {
@Override
public int Janky(int arg) throws TException {
- return 0;
+ assertEquals(1, arg);
+ return 3;
}
@Override
@@ -99,7 +100,7 @@
@Override
public void onComplete(Janky_call response) {
try {
- assertEquals(0, response.getResult());
+ assertEquals(3, response.getResult());
jankyReturned.set(true);
} catch (TException e) {
fail("unexpected exception: " + e);