[ 
https://issues.apache.org/jira/browse/THRIFT-2988?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14321368#comment-14321368
 ] 

Jens Geyer commented on THRIFT-2988:
------------------------------------

I'm not so much into the Java stuff but my feelings go towards modifying 
codegen to match what is happening. Deriving TException from TBase sounds wrong 
to me, AFAIK nobody else does this.

> Class Cast Exception in Generated Java AsyncProcessor
> -----------------------------------------------------
>
>                 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 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 
> {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 : [code-in-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 code 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)

Reply via email to