Browse Source

HADOOP-6686. Remove redundant exception class name from the exception message for the exceptions thrown at RPC client. Contributed by Suresh Srinivas.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@937183 13f79535-47bb-0310-9956-ffa450edef68
Suresh Srinivas 15 years ago
parent
commit
50f24d774e

+ 3 - 0
CHANGES.txt

@@ -7,6 +7,9 @@ Trunk (unreleased changes)
     HADOOP-6299. Reimplement the UserGroupInformation to use the OS
     HADOOP-6299. Reimplement the UserGroupInformation to use the OS
     specific and Kerberos JAAS login. (omalley)
     specific and Kerberos JAAS login. (omalley)
 
 
+    HADOOP-6686. Remove redundant exception class name from the exception
+    message for the exceptions thrown at RPC client. (suresh)
+
   NEW FEATURES
   NEW FEATURES
 
 
     HADOOP-6284. Add a new parameter, HADOOP_JAVA_PLATFORM_OPTS, to
     HADOOP-6284. Add a new parameter, HADOOP_JAVA_PLATFORM_OPTS, to

+ 5 - 6
src/java/org/apache/hadoop/ipc/RemoteException.java

@@ -88,12 +88,7 @@ public class RemoteException extends IOException {
       throws Exception {
       throws Exception {
     Constructor<? extends IOException> cn = cls.getConstructor(String.class);
     Constructor<? extends IOException> cn = cls.getConstructor(String.class);
     cn.setAccessible(true);
     cn.setAccessible(true);
-    String firstLine = this.getMessage();
-    int eol = firstLine.indexOf('\n');
-    if (eol>=0) {
-      firstLine = firstLine.substring(0, eol);
-    }
-    IOException ex = cn.newInstance(firstLine);
+    IOException ex = cn.newInstance(this.getMessage());
     ex.initCause(this);
     ex.initCause(this);
     return ex;
     return ex;
   }
   }
@@ -117,4 +112,8 @@ public class RemoteException extends IOException {
     return new RemoteException(attrs.getValue("class"),
     return new RemoteException(attrs.getValue("class"),
         attrs.getValue("message")); 
         attrs.getValue("message")); 
   }
   }
+  
+  public String toString() {
+    return className + ": " + getMessage();
+  }
 }
 }

+ 5 - 0
src/java/org/apache/hadoop/ipc/Server.java

@@ -1276,6 +1276,11 @@ public abstract class Server {
             LOG.info(getName()+", call "+call+": error: " + e, e);
             LOG.info(getName()+", call "+call+": error: " + e, e);
             errorClass = e.getClass().getName();
             errorClass = e.getClass().getName();
             error = StringUtils.stringifyException(e);
             error = StringUtils.stringifyException(e);
+            // Remove redundant error class name from the beginning of the stack trace
+            String exceptionHdr = errorClass + ": ";
+            if (error.startsWith(exceptionHdr)) {
+              error = error.substring(exceptionHdr.length());
+            }
           }
           }
           CurCall.set(null);
           CurCall.set(null);
           synchronized (call.connection.responseQueue) {
           synchronized (call.connection.responseQueue) {