string extends_client = "";
if (tservice->get_extends() != NULL) {
extends = type_name(tservice->get_extends()) + ".AsyncClient";
- // extends_client = " extends " + extends + ".AsyncClient";
}
indent(f_service_) <<
// Main method body
indent(f_service_) << "public " << function_signature_async(*f_iter, false) << " throws TException {" << endl;
indent(f_service_) << " checkReady();" << endl;
- indent(f_service_) << " " << funclassname << " method_call = new " + funclassname + "(" << async_argument_list(*f_iter, arg_struct, ret_type) << ", this, protocolFactory, transport);" << endl;
+ indent(f_service_) << " " << funclassname << " method_call = new " + funclassname + "(" << async_argument_list(*f_iter, arg_struct, ret_type) << ", this, protocolFactory, transport);" << endl;
+ indent(f_service_) << " this.currentMethod = method_call;" << endl;
indent(f_service_) << " manager.call(method_call);" << endl;
indent(f_service_) << "}" << endl;
protected final TProtocolFactory protocolFactory;
protected final TNonblockingTransport transport;
protected final TAsyncClientManager manager;
- private TAsyncMethodCall currentMethod;
+ protected TAsyncMethodCall currentMethod;
private Throwable error;
private long timeout;
--- /dev/null
+package org.apache.thrift.async;
+
+import org.apache.thrift.TException;
+
+import junit.framework.TestCase;
+import thrift.test.Srv;
+import thrift.test.Srv.AsyncClient;
+
+public class TestTAsyncClient extends TestCase {
+ public void testRaisesExceptionWhenUsedConcurrently() throws Exception {
+ TAsyncClientManager mockClientManager = new TAsyncClientManager() {
+ @Override
+ public void call(TAsyncMethodCall method) throws TException {
+ // do nothing
+ }
+ };
+
+ Srv.AsyncClient c = new AsyncClient(null, mockClientManager, null);
+ c.Janky(0, null);
+ try {
+ c.checkReady();
+ fail("should have hit an exception");
+ } catch (Exception e) {
+ // awesome
+ }
+ }
+}