浏览代码

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 年之前
父节点
当前提交
50f24d774e
共有 3 个文件被更改,包括 13 次插入6 次删除
  1. 3 0
      CHANGES.txt
  2. 5 6
      src/java/org/apache/hadoop/ipc/RemoteException.java
  3. 5 0
      src/java/org/apache/hadoop/ipc/Server.java

+ 3 - 0
CHANGES.txt

@@ -7,6 +7,9 @@ Trunk (unreleased changes)
     HADOOP-6299. Reimplement the UserGroupInformation to use the OS
     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
 
     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 {
     Constructor<? extends IOException> cn = cls.getConstructor(String.class);
     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);
     return ex;
   }
@@ -117,4 +112,8 @@ public class RemoteException extends IOException {
     return new RemoteException(attrs.getValue("class"),
         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);
             errorClass = e.getClass().getName();
             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);
           synchronized (call.connection.responseQueue) {