You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "deepankar (JIRA)" <ji...@apache.org> on 2015/02/09 23:32:35 UTC

[jira] [Created] (THRIFT-2988) Class Cast Exception in Generated Java AsyncProcess

deepankar created THRIFT-2988:
---------------------------------

             Summary: Class Cast Exception in Generated Java AsyncProcess
                 Key: THRIFT-2988
                 URL: https://issues.apache.org/jira/browse/THRIFT-2988
             Project: Thrift
          Issue Type: Bug
          Components: Java - Compiler, Java - Library
            Reporter: deepankar
            Priority: Critical


When using Async Processor, there is a class cast exception when you call the onError function on AsyncMethodCallback with an exception other than the expected exception 

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

{code:title=Bar.java|borderStyle=solid}

    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;
{code}
link : [github-trunk |https://github.com/apache/thrift/blob/master/compiler/cpp/src/generate/t_java_generator.cc#L3209-L3221]

There are two ways to solve this :
* one is make TApplicationException to extend TBase
* another is to change the generation logic here 

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







--
This message was sent by Atlassian JIRA
(v6.3.4#6332)