Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
0.11.0, 0.15.0, 0.16.0
-
None
Description
Exceptions thrown in void methods are lost on the client side when using an asynchronous Java client.
For non-void methods, generated getResult() looks like this:
public java.lang.String getResult() throws TExampleException, org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new java.lang.IllegalStateException("Method call not finished!"); } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); return (new Client(prot)).recv_returnString(); }
For void methods like:
public Void getResult() throws TExampleException, org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new java.lang.IllegalStateException("Method call not finished!"); } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); return null; }
There are no call to (new Client(prot)).recv_returnVoidThrows() here.
But in recv_returnVoidThrows():
public void recv_returnVoidThrows() throws TExampleException, org.apache.thrift.TException { returnVoidThrows_result result = new returnVoidThrows_result(); receiveBase(result, "returnVoidThrows"); if (result.error != null) { throw result.error; } return; }
the received response is read and the received exceptions are thrown.
The correct getResult() for void methods should look like this:
public Void getResult() throws TExampleException, org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new java.lang.IllegalStateException("Method call not finished!"); } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); (new Client(prot)).recv_returnVoidThrows(); return null; }
Attached test (bug-async-void-meths-lost-exception.zip) demonstrates this issue.
Attachments
Attachments
Issue Links
- links to