[ 
https://issues.apache.org/jira/browse/THRIFT-5260?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

zero updated THRIFT-5260:
-------------------------
    Description: 
The oneway method 'testOneway' in file 'test/ThriftTest.thrift', for instance, 
generated code in file 'test/lua/gen-lua/ThriftTest_ThriftTest.lua' as follows:

function ThriftTestProcessor:process_testOneway(seqid, iprot, oprot, server_ctx)
 local args = testOneway_args:new{}
 local reply_type = TMessageType.REPLY
 args:read(iprot)
 iprot:readMessageEnd()
 local result = testOneway_result:new{}
 local status, res = pcall(self.handler.testOneway, self.handler, 
args.secondsToSleep)
 if not status then
 reply_type = TMessageType.EXCEPTION
 result = TApplicationException:new

{message = res}

else
 result.success = res
 end
 oprot:writeMessageBegin('testOneway', reply_type, seqid)
 result:write(oprot)
 oprot:writeMessageEnd()
 oprot.trans:flush()
 end

The 'testOneway_result' is undefined and I think it is wrong to write the 
'result' to the 'oprot' since it is nil, but at the same time it is necessary 
for every process functions to return values from each handler.

 

[I New a pull request here: 
https://github.com/apache/thrift/pull/2212|https://github.com/apache/thrift/pull/2212]

  was:
The oneway method 'testOneway' in file 'test/ThriftTest.thrift', for instance, 
generated code in file 'test/lua/gen-lua/ThriftTest_ThriftTest.lua' as follows:

function ThriftTestProcessor:process_testOneway(seqid, iprot, oprot, server_ctx)
 local args = testOneway_args:new{}
 local reply_type = TMessageType.REPLY
 args:read(iprot)
 iprot:readMessageEnd()
 local result = testOneway_result:new{}
 local status, res = pcall(self.handler.testOneway, self.handler, 
args.secondsToSleep)
 if not status then
 reply_type = TMessageType.EXCEPTION
 result = TApplicationException:new

{message = res}

else
 result.success = res
 end
 oprot:writeMessageBegin('testOneway', reply_type, seqid)
 result:write(oprot)
 oprot:writeMessageEnd()
 oprot.trans:flush()
 end

The 'testOneway_result' is undefined and I think it is wrong to write the 
'result' to the 'oprot' since it is nil, but at the same time it is necessary 
for every process functions to return values from each handler.

 

[I New a pull request herer: 
https://github.com/apache/thrift/pull/2212|https://github.com/apache/thrift/pull/2212]


> Fix the thrift compiler generate problematic lua code for the oneway method
> ---------------------------------------------------------------------------
>
>                 Key: THRIFT-5260
>                 URL: https://issues.apache.org/jira/browse/THRIFT-5260
>             Project: Thrift
>          Issue Type: Bug
>          Components: Lua - Compiler
>    Affects Versions: 0.13.0
>            Reporter: zero
>            Priority: Major
>
> The oneway method 'testOneway' in file 'test/ThriftTest.thrift', for 
> instance, generated code in file 'test/lua/gen-lua/ThriftTest_ThriftTest.lua' 
> as follows:
> function ThriftTestProcessor:process_testOneway(seqid, iprot, oprot, 
> server_ctx)
>  local args = testOneway_args:new{}
>  local reply_type = TMessageType.REPLY
>  args:read(iprot)
>  iprot:readMessageEnd()
>  local result = testOneway_result:new{}
>  local status, res = pcall(self.handler.testOneway, self.handler, 
> args.secondsToSleep)
>  if not status then
>  reply_type = TMessageType.EXCEPTION
>  result = TApplicationException:new
> {message = res}
> else
>  result.success = res
>  end
>  oprot:writeMessageBegin('testOneway', reply_type, seqid)
>  result:write(oprot)
>  oprot:writeMessageEnd()
>  oprot.trans:flush()
>  end
> The 'testOneway_result' is undefined and I think it is wrong to write the 
> 'result' to the 'oprot' since it is nil, but at the same time it is necessary 
> for every process functions to return values from each handler.
>  
> [I New a pull request here: 
> https://github.com/apache/thrift/pull/2212|https://github.com/apache/thrift/pull/2212]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to