When implementing methods of remote interface, what's the design pattern for handling exceptions in those methods? Should I catch all Throwables and rethrow RemoteException, or will the stub take care of it?

swarraj kulkarni

It is the choice of developer rather than any set design pattern. If the remote server wants to provide summary information about the cause of failure, then it's better to have the exception caught at the server side and a concise version passed to the client. Further in debugging mode, the stack trace does not get passed on to the stub since it does not implement the Serializable interface. In this case, it is better to catch the exception at the server and wrap the stack trace within your own exception class before passing it to the client.

On the other hand, if the developer wants a simple design and does not worry about the exact details of the exception cause (stack trace), the server can just throw the exception and the client can catch it.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact