You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "James E. King, III (JIRA)" <ji...@apache.org> on 2017/06/14 14:37:00 UTC
[jira] [Created] (THRIFT-4228) Generated java service code emits a
dead local store
James E. King, III created THRIFT-4228:
------------------------------------------
Summary: Generated java service code emits a dead local store
Key: THRIFT-4228
URL: https://issues.apache.org/jira/browse/THRIFT-4228
Project: Thrift
Issue Type: Bug
Components: Java - Compiler
Affects Versions: 0.10.0
Reporter: James E. King, III
Priority: Trivial
I created a simple service:
{noformat}
namespace java org.apache.thrift.test
service DeadLocalStore
{
void doNothing();
}
{noformat}
I compiled it with {{thrift --gen java}}. The resulting generated code has some dead local stores that are unnecessary:
{noformat}
public static class doNothing_call extends org.apache.thrift.async.TAsyncMethodCall<Void> {
public doNothing_call(org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
super(client, protocolFactory, transport, resultHandler, false);
}
public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("doNothing", org.apache.thrift.protocol.TMessageType.CALL, 0));
doNothing_args args = new doNothing_args();
args.write(prot);
prot.writeMessageEnd();
}
public Void getResult() throws 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;
}
}
{noformat}
Above, memoryTransport and prot are unnecessary.
{noformat}
private static class doNothing_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<doNothing_args> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, doNothing_args struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, doNothing_args struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
}
}
{noformat}
Above, iprot and oprot are unnecessary.
{noformat}
public void onError(java.lang.Exception e) {
byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
org.apache.thrift.TSerializable msg;
doNothing_result result = new doNothing_result();
if (e instanceof org.apache.thrift.transport.TTransportException) {
_LOGGER.error("TTransportException inside handler", e);
fb.close();
return;
} else if (e instanceof org.apache.thrift.TApplicationException) {
_LOGGER.error("TApplicationException inside handler", e);
msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
msg = (org.apache.thrift.TApplicationException)e;
} else {
_LOGGER.error("Exception inside handler", e);
msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
}
try {
fcall.sendResponse(fb,msg,msgType,seqid);
} catch (java.lang.Exception ex) {
_LOGGER.error("Exception writing to internal frame buffer", ex);
fb.close();
}
}
{noformat}
Above, result is unnecessary.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)