1 2 Previous Next 24 Replies Latest reply: Oct 24, 2008 1:37 AM by Ron Sigal RSS

Exception propagation using HTTP servlet transport on 1.4.4

Alex Besogonov Newbie

There's a bug in ServletServerInvoker in 1.4.4 version of remoting.

'processRequest' methods do not support propagation of exceptions to remote clients.

This code:

 try
 {
 // call transport on the subclass, get the result to handback
 invocationResponse = invoke(invocationRequest);
 }
 catch(Throwable ex)
 {
 log.debug("Error thrown calling invoke on server invoker.", ex);
 invocationResponse = ex;
 isError = true;
 }

 //Start with response code of 204 (no content), then if is a return from handler, change to 200 (ok)
 int status = 204;
 if(invocationResponse != null)
 {
 if(isError)
 {
 response.sendError(500, "Error occurred processing invocation request. ");
 }
 else
 {
 status = 200;
 }
 }

sends "500 Server Error" message in response body to client. Client then tries to unmarshal this message using ObjectInputStream and fails.

The simple fix is:
 try
 {
 // call transport on the subclass, get the result to handback
 invocationResponse = invoke(invocationRequest);
 }
 catch(Throwable ex)
 {
 log.debug("Error thrown calling invoke on server invoker.", ex);
 invocationResponse = ex;

 String sessionId=null;
 if (invocationRequest instanceof InvocationRequest)
 sessionId=((InvocationRequest)invocationRequest).getSessionId();
 invocationResponse=new InvocationResponse(sessionId,ex,true,null);
 //isError = true;
 }


It seems to be working for me.

Should I create JIRA bug for this issue?

1 2 Previous Next