HADOOP-10543. RemoteException's unwrapRemoteException method failed for PathIOException. Contributed by Yongjun Zhang.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1591181 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Aaron Myers 2014-04-30 03:22:20 +00:00
parent 0532b8bad1
commit 74921bd7bb
3 changed files with 29 additions and 3 deletions

View File

@ -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

View File

@ -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) {

View File

@ -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 {
@ -53,4 +55,24 @@ public class TestPathExceptions {
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);
}
}