Andrew Dodd created THRIFT-1663:
-----------------------------------

             Summary: Java Thrift server is not throwing exceptions
                 Key: THRIFT-1663
                 URL: https://issues.apache.org/jira/browse/THRIFT-1663
             Project: Thrift
          Issue Type: Bug
          Components: Java - Compiler
    Affects Versions: 0.8
            Reporter: Andrew Dodd


Whilst trying out Thrift using the tutorial code, I noticed the message "Whoa 
we can divide by 0" being shown in the console, indicating that the 
InvalidOperationException was not being thrown to the client.

Looking at the tutorial code, the method calculate returns i32. Digging in a 
bit, in the recv_calculate() method that the client excuted, I can see that if 
the isSetSuccess method returns true (which it always does as success is set to 
0 in the server; this field actually appears to be the field where the return 
value of the function is stored) then the value of success is returned. 

To fix this, I have changed the order of the following code:

      if (result.isSetSuccess()) {
        return result.success;
      }
      if (result.ouch != null) {
        throw result.ouch;
      }

By putting the check for the exception first, then the exception is thrown 
correctly.

Since I'm new to Thrift I have no idea what the correct solution to this bug 
would be.

Also, this appears to be a reproduction of this issue: 
http://mail-archives.apache.org/mod_mbox/thrift-user/201112.mbox/ajax/%3C2672B8B3-5A1F-4656-B335-8EE109DEA38E%40163.com%3E

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to