diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index bcbff16cb13..736d8504adb 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -428,6 +428,9 @@ Release 2.5.0 - UNRELEASED HADOOP-10547. Give SaslPropertiesResolver.getDefaultProperties() public scope. (Benoy Antony via Arpit Agarwal) + HADOOP-10543. RemoteException's unwrapRemoteException method failed for + PathIOException. (Yongjun Zhang via atm) + Release 2.4.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/PathIOException.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/PathIOException.java index 2c73f11ff2d..459a83669aa 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/PathIOException.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/PathIOException.java @@ -40,7 +40,7 @@ public class PathIOException extends IOException { * @param path for the exception */ public PathIOException(String path) { - this(path, EIO, null); + this(path, EIO); } /** @@ -59,7 +59,8 @@ public class PathIOException extends IOException { * @param error custom string to use an the error text */ public PathIOException(String path, String error) { - this(path, error, null); + super(error); + this.path = path; } protected PathIOException(String path, String error, Throwable cause) { diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestPathExceptions.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestPathExceptions.java index f0a0f46acb9..d4f000576b0 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestPathExceptions.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestPathExceptions.java @@ -19,11 +19,13 @@ package org.apache.hadoop.fs.shell; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.io.IOException; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.PathIOException; +import org.apache.hadoop.ipc.RemoteException; import org.junit.Test; public class TestPathExceptions { @@ -52,5 +54,25 @@ public class TestPathExceptions { assertEquals(new Path(path), pe.getPath()); assertEquals("`" + path + "': " + error, pe.getMessage()); } - + + @Test + public void testRemoteExceptionUnwrap() throws Exception { + PathIOException pe; + RemoteException re; + IOException ie; + + pe = new PathIOException(path); + re = new RemoteException(PathIOException.class.getName(), "test constructor1"); + ie = re.unwrapRemoteException(); + assertTrue(ie instanceof PathIOException); + ie = re.unwrapRemoteException(PathIOException.class); + assertTrue(ie instanceof PathIOException); + + pe = new PathIOException(path, "constructor2"); + re = new RemoteException(PathIOException.class.getName(), "test constructor2"); + ie = re.unwrapRemoteException(); + assertTrue(ie instanceof PathIOException); + ie = re.unwrapRemoteException(PathIOException.class); + assertTrue(ie instanceof PathIOException); + } }