hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r387660 - in /lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc: Client.java Server.java
Date Tue, 21 Mar 2006 22:50:04 GMT
Author: cutting
Date: Tue Mar 21 14:50:04 2006
New Revision: 387660

URL: http://svn.apache.org/viewcvs?rev=387660&view=rev
Log:
Fix for HADOOP-44.  The error string for remote exceptions now contains the full remote stack
trace.  Remote exceptions are now also re-thrown on the client as RemoteException rather than
IOException, so that they can be distinguished from other IOExceptions.

Modified:
    lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/Client.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/Server.java

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/Client.java
URL: http://svn.apache.org/viewcvs/lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/Client.java?rev=387660&r1=387659&r2=387660&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/Client.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/Client.java Tue Mar 21 14:50:04 2006
@@ -29,6 +29,8 @@
 import java.io.FilterInputStream;
 import java.io.FilterOutputStream;
 
+import java.rmi.RemoteException;
+
 import java.util.Hashtable;
 import java.util.logging.Logger;
 import java.util.logging.Level;
@@ -298,7 +300,7 @@
       } while (!call.done && wait > 0);
 
       if (call.error != null) {
-        throw new IOException(call.error);
+        throw new RemoteException(call.error);
       } else if (!call.done) {
         throw new IOException("timed out waiting for response");
       } else {

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/Server.java
URL: http://svn.apache.org/viewcvs/lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/Server.java?rev=387660&r1=387659&r2=387660&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/Server.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/Server.java Tue Mar 21 14:50:04 2006
@@ -22,6 +22,8 @@
 import java.io.DataOutputStream;
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
+import java.io.StringWriter;
+import java.io.PrintWriter;
 
 import java.net.Socket;
 import java.net.ServerSocket;
@@ -214,10 +216,10 @@
             value = call(call.param);             // make the call
           } catch (IOException e) {
             LOG.log(Level.INFO, getName() + " call error: " + e, e);
-            error = e.getMessage();
+            error = getStackTrace(e);
           } catch (Exception e) {
             LOG.log(Level.INFO, getName() + " call error: " + e, e);
-            error = e.toString();
+            error = getStackTrace(e);
           }
             
           DataOutputStream out = call.connection.out;
@@ -236,6 +238,15 @@
       }
       LOG.info(getName() + ": exiting");
     }
+
+    private String getStackTrace(Throwable throwable) {
+      StringWriter stringWriter = new StringWriter();
+      PrintWriter printWriter = new PrintWriter(stringWriter);
+      throwable.printStackTrace(printWriter);
+      printWriter.flush();
+      return stringWriter.toString();
+    }
+
   }
   
   /** Constructs a server listening on the named port.  Parameters passed must



Mime
View raw message