2004-09-24 Ilya Perminov <iperminov@logicalsoft.com>
authorIlya Perminov <iperminov@logicalsoft.com>
Fri, 24 Sep 2004 12:29:48 +0000 (12:29 +0000)
committerMichael Koch <mkoch@gcc.gnu.org>
Fri, 24 Sep 2004 12:29:48 +0000 (12:29 +0000)
* gnu/java/rmi/server/UnicastServer.java
(incomingMessageCall): Added code to handle Errors.
* gnu/java/rmi/server/UnicastServerRef.java
(incomingMessageCall): Added code to handle Errors.

From-SVN: r88030

libjava/ChangeLog
libjava/gnu/java/rmi/server/UnicastServer.java
libjava/gnu/java/rmi/server/UnicastServerRef.java

index 107a673c3e34de90ac295f49b2b967a38ff80a56..ab395dc22af4902f5abf38f80b88ad189abba260 100644 (file)
@@ -1,3 +1,11 @@
+2004-09-24  Ilya Perminov  <iperminov@logicalsoft.com>
+
+       * gnu/java/rmi/server/UnicastServer.java
+       (incomingMessageCall): Added code to handle Errors.
+       * gnu/java/rmi/server/UnicastServerRef.java
+       (incomingMessageCall): Added code to handle Errors.
+
+
 2004-09-24  Tom Tromey  <tromey@redhat.com>
 
        * java/lang/ClassLoader.java (loadedClasses): Declare as HashMap.
index ace43f0186166427b12a3845750deee17a145b57..4230954044202916ece7fb808fb0fd11b3f29101 100644 (file)
@@ -46,6 +46,7 @@ import java.net.InetAddress;
 import java.util.Hashtable;
 import java.net.UnknownHostException;
 import java.rmi.Remote;
+import java.rmi.ServerError;
 import java.rmi.server.ObjID;
 import java.rmi.server.UnicastRemoteObject;
 import java.rmi.server.UID;
@@ -136,6 +137,10 @@ private static void incomingMessageCall(UnicastConnection conn) throws IOExcepti
                        returnval = e;
                        returncode = RETURN_NACK;
                }
+                catch (Error e) {
+                       returnval = new ServerError ("An Error is thrown while processing the invocation on the server", e);
+                       returncode = RETURN_NACK;
+                }
        }
        else {
                returnval = new NoSuchObjectException("");
index 3e9529c598b3b56331863eb2a5d3a64114911b8f..1c5823a7070fdfb712568a220bded0f98284226e 100644 (file)
@@ -284,7 +284,16 @@ public Object incomingMessageCall(UnicastConnection conn, int method, long hash)
                try{
                    ret = meth.invoke(myself, args);
                }catch(InvocationTargetException e){
-                   throw (Exception)(e.getTargetException());
+                    Throwable cause = e.getTargetException();
+                    if (cause instanceof Exception) {
+                        throw (Exception)cause;
+                    }
+                    else if (cause instanceof Error) {
+                        throw (Error)cause;
+                    }
+                    else {
+                        throw new Error("The remote method threw a java.lang.Throwable that is neither java.lang.Exception nor java.lang.Error.", e);
+                    }
                }
                return ret;
        }