diff options
author | Stephan Bergmann <sb@openoffice.org> | 2002-09-17 14:07:24 +0000 |
---|---|---|
committer | Stephan Bergmann <sb@openoffice.org> | 2002-09-17 14:07:24 +0000 |
commit | 967272f60aaaaf2710008fbd52976ab4b58e3cbf (patch) | |
tree | ce181c20067664016d5e2fb580c0e4cecf080338 /jurt | |
parent | 23196937697efeb94385cb7fe05038f0fb5948de (diff) |
#98508# In execute, do not call sendReply a second time with an exception in case the regular sendReply caused an exception.
Diffstat (limited to 'jurt')
-rw-r--r-- | jurt/com/sun/star/lib/uno/environments/remote/Job.java | 109 |
1 files changed, 60 insertions, 49 deletions
diff --git a/jurt/com/sun/star/lib/uno/environments/remote/Job.java b/jurt/com/sun/star/lib/uno/environments/remote/Job.java index 9fe0de55efb7..5645f6af2096 100644 --- a/jurt/com/sun/star/lib/uno/environments/remote/Job.java +++ b/jurt/com/sun/star/lib/uno/environments/remote/Job.java @@ -2,9 +2,9 @@ * * $RCSfile: Job.java,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: jl $ $Date: 2002-07-17 10:54:11 $ + * last change: $Author: sb $ $Date: 2002-09-17 15:07:24 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -50,7 +50,7 @@ * * The Initial Developer of the Original Code is: Sun Microsystems, Inc. * - * Copyright: 2000 by Sun Microsystems, Inc. + * Copyright: 2002 by Sun Microsystems, Inc. * * All Rights Reserved. * @@ -81,7 +81,7 @@ import com.sun.star.uno.UnoRuntime; * The Job is an abstraction for tasks which have to be done * remotely because of a method invocation. * <p> - * @version $Revision: 1.11 $ $ $Date: 2002-07-17 10:54:11 $ + * @version $Revision: 1.12 $ $ $Date: 2002-09-17 15:07:24 $ * @author Kay Ramme * @see com.sun.star.lib.uno.environments.remote.ThreadID * @see com.sun.star.lib.uno.environments.remote.IReceiver @@ -150,59 +150,72 @@ public class Job { } /** - * Executes the job. - * <p> - * @return returns true if the operation is a reply + * Execute the job. + * + * @return the result of the message. */ public Object execute() throws Throwable { - Object params[][] = new Object[1][]; - - Object result = _iMessage.getData(params); - - if(DEBUG) System.err.println("##### " + getClass().getName() + ".execute:" + result + " " + _iMessage.isException()); - - if(_iMessage.isException()) - throw (Throwable)result; + Object[][] msgParams = new Object[1][]; + Object msgResult = _iMessage.getData(msgParams); - try { - if(_iMessage.getOperation() != null) { // it is a request - Object xresult = null; - - if(_iMessage.getOperation().equals("queryInterface")) - xresult = dispatch_queryInterface((Type)params[0][0]); - else - xresult = dispatch_MethodCall(params[0]); - - if(_iMessage.mustReply()) - _iReceiver.sendReply(false, _iMessage.getThreadId(), xresult); - } + if (DEBUG) { + System.err.println("##### " + getClass().getName() + ".execute: " + + msgResult + " " + _iMessage.isException()); } - catch(Exception exception) { -// catch(InvocationTargetException invocationTargetException) { - Throwable throwable = exception; - if(exception instanceof InvocationTargetException) - throwable = ((InvocationTargetException)exception).getTargetException();; + if (_iMessage.isException()) { + throw (Throwable) msgResult; + } - if(DEBUG) { - System.err.println("##### Job.execute - exception occured:" + throwable); - throwable.printStackTrace(); - } - // Here we have to be aware of non UNO exceptions, cause they may kill - // a remote side (which does not know anything about theire types) - if(!(throwable instanceof com.sun.star.uno.Exception) - && !(throwable instanceof com.sun.star.uno.RuntimeException)) { - StringWriter stringWriter = new StringWriter(); - throwable.printStackTrace(new PrintWriter(stringWriter)); - - throwable = new com.sun.star.uno.RuntimeException("java exception: " + stringWriter.toString(), null); + String operation = _iMessage.getOperation(); + if (operation != null) { // if it is a request + Object result = null; + Throwable exception = null; + + try { + result = operation.equals("queryInterface") + ? dispatch_queryInterface((Type) msgParams[0][0]) + : dispatch_MethodCall(msgParams[0]); + } catch (InvocationTargetException e) { + if (DEBUG) { + e.printStackTrace(System.err); + } + exception = e.getCause(); + if (exception == null) { + exception = e; + } + } catch (Exception e) { + if (DEBUG) { + e.printStackTrace(System.err); + } + exception = e; } - if(_iMessage.mustReply()) - _iReceiver.sendReply(true, _iMessage.getThreadId(), throwable); + if (_iMessage.mustReply()) { + if (exception == null) { + _iReceiver.sendReply(false, _iMessage.getThreadId(), + result); + } else { + // Here we have to be aware of non-UNO exceptions, because + // they may kill a remote side which does not know anything + // about their types: + if (exception != null + && !(exception instanceof com.sun.star.uno.Exception) + && !(exception instanceof + com.sun.star.uno.RuntimeException)) { + StringWriter writer = new StringWriter(); + exception.printStackTrace(new PrintWriter(writer)); + exception = new com.sun.star.uno.RuntimeException( + "Java exception: " + writer, null); + } + + _iReceiver.sendReply(true, _iMessage.getThreadId(), + exception); + } + } } - return result; + return msgResult; } /** @@ -281,5 +294,3 @@ public class Job { // _disposeId = null; } } - - |