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

Class Cast Exception in Generated Java AsyncProcessor

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Duplicate
    • None
    • None
    • None

    Description

      When using a generated Async Processor for any service, there is a class cast exception that can happen when you call the onError function on a returned AsyncMethodCallback (returned from any class that extends AsyncProcessFunction) with an exception other than the expected exception for that method

      This occurs because the org.apache.thrift.TApplicationException being cast as (org.apache.thrift.TBase) in the generated code for a service

      Bar.java
          indent(f_service_) << "{" << endl;
          indent_up();
          indent(f_service_) << "msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;" << endl;
          indent(f_service_) << "msg = (org.apache.thrift.TBase)new "
                                "org.apache.thrift.TApplicationException(org.apache.thrift."
                                "TApplicationException.INTERNAL_ERROR, e.getMessage());" << endl;
          indent_down();
          indent(f_service_) << "}" << endl;
      

      link : code-in-github-trunk

      There are two ways to solve this :

      • one is make TApplicationException to extend TBase
      • another is to change the code generation logic here

      I can put up a patch based on what approach is advised ?

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              dvdreddy deepankar
              Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: