Browse Source

HADOOP-3844. Include message of local exception in RPC client failures.
(Steve Loughran via omalley)


git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@685342 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley 17 years ago
parent
commit
d9ee589259

+ 3 - 0
CHANGES.txt

@@ -178,6 +178,9 @@ Trunk (unreleased changes)
     HADOOP-3852. Add ShellCommandExecutor.toString method to make nicer
     HADOOP-3852. Add ShellCommandExecutor.toString method to make nicer
     error messages. (Steve Loughran via omalley)
     error messages. (Steve Loughran via omalley)
 
 
+    HADOOP-3844. Include message of local exception in RPC client failures.
+    (Steve Loughran via omalley)
+
   OPTIMIZATIONS
   OPTIMIZATIONS
 
 
     HADOOP-3556. Removed lock contention in MD5Hash by changing the 
     HADOOP-3556. Removed lock contention in MD5Hash by changing the 

+ 3 - 1
src/core/org/apache/hadoop/ipc/Client.java

@@ -708,7 +708,9 @@ public class Client {
           throw call.error;
           throw call.error;
         } else { // local exception
         } else { // local exception
           throw (IOException)new IOException(
           throw (IOException)new IOException(
-              "Call failed on local exception").initCause(call.error);
+              "Call to "+ addr + " failed on local exception: "
+                      + call.error.getMessage())
+                  .initCause(call.error);
         }
         }
       } else {
       } else {
         return call.value;
         return call.value;

+ 14 - 5
src/test/org/apache/hadoop/ipc/TestIPC.java

@@ -211,16 +211,25 @@ public class TestIPC extends TestCase {
   public void testStandAloneClient() throws Exception {
   public void testStandAloneClient() throws Exception {
     testParallel(10, false, 2, 4, 2, 4, 100);
     testParallel(10, false, 2, 4, 2, 4, 100);
     Client client = new Client(LongWritable.class, conf);
     Client client = new Client(LongWritable.class, conf);
-    boolean hasException = false;
+    InetSocketAddress address = new InetSocketAddress("127.0.0.1", 10);
     try {
     try {
-      client.call(new LongWritable(RANDOM.nextLong()), 
-          new InetSocketAddress("127.0.0.1", 10));
+      client.call(new LongWritable(RANDOM.nextLong()),
+              address);
+      fail("Expected an exception to have been thrown");
     } catch (IOException e) {
     } catch (IOException e) {
-      hasException = true;
+      String message = e.getMessage();
+      String addressText = address.toString();
+      assertTrue("Did not find "+addressText+" in "+message,
+              message.contains(addressText));
+      Throwable cause=e.getCause();
+      assertNotNull("No nested exception in "+e,cause);
+      String causeText=cause.getMessage();
+      assertTrue("Did not find " + causeText + " in " + message,
+              message.contains(causeText));
     }
     }
-    assertTrue (hasException);
   }
   }
 
 
+
   public static void main(String[] args) throws Exception {
   public static void main(String[] args) throws Exception {
 
 
     //new TestIPC("test").testSerial(5, false, 2, 10, 1000);
     //new TestIPC("test").testSerial(5, false, 2, 10, 1000);