import java.util.Iterator;
import java.util.concurrent.ConcurrentLinkedQueue;
+import org.apache.thrift.TException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
selectThread.start();
}
- public void call(TAsyncMethodCall method) {
+ public void call(TAsyncMethodCall method) throws TException {
+ method.prepareMethodCall();
pendingCalls.add(method);
selectThread.getSelector().wakeup();
}
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;
this.isOneway = isOneway;
this.state = State.WRITING_REQUEST_SIZE;
- prepareMethodCall();
}
protected State getState() {
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);
public class SrvHandler implements Iface {
@Override
public int Janky(int arg) throws TException {
- return 0;
+ assertEquals(1, arg);
+ return 3;
}
@Override
@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);