Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-1663

Java Thrift server is not throwing exceptions

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 0.8
    • 0.9
    • Java - Compiler
    • None

    Description

      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

      Attachments

        Issue Links

          Activity

            People

              jfarrell Jake Farrell
              ad13 Andrew Dodd
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: