You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by in...@apache.org on 2019/08/12 03:34:56 UTC
[hadoop] branch trunk updated: HADOOP-16453. Update how exceptions
are handled in NetUtils. Contributed by Lisheng Sun.
This is an automated email from the ASF dual-hosted git repository.
inigoiri pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push:
new 6b4564f HADOOP-16453. Update how exceptions are handled in NetUtils. Contributed by Lisheng Sun.
6b4564f is described below
commit 6b4564f1d59ab679512be0d244165e1f272cb9bd
Author: Inigo Goiri <in...@apache.org>
AuthorDate: Sun Aug 11 20:34:36 2019 -0700
HADOOP-16453. Update how exceptions are handled in NetUtils. Contributed by Lisheng Sun.
---
.../src/main/java/org/apache/hadoop/net/NetUtils.java | 10 +++++++---
.../src/test/java/org/apache/hadoop/ipc/TestIPC.java | 7 +++----
.../src/test/java/org/apache/hadoop/net/TestNetUtils.java | 15 +++++----------
3 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java
index acdec93..d98254c 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java
@@ -804,7 +804,11 @@ public class NetUtils {
+ ";"
+ see("SocketException"));
} else {
- // Return instance of same type if Exception has a String constructor
+ // 1. Return instance of same type with exception msg if Exception has a
+ // String constructor.
+ // 2. Return instance of same type if Exception doesn't have a String
+ // constructor.
+ // Related HADOOP-16453.
return wrapWithMessage(exception,
"DestHost:destPort " + destHost + ":" + destPort
+ " , LocalHost:localPort " + localHost
@@ -832,9 +836,9 @@ public class NetUtils {
Constructor<? extends Throwable> ctor = clazz.getConstructor(String.class);
Throwable t = ctor.newInstance(msg);
return (T)(t.initCause(exception));
+ } catch (NoSuchMethodException e) {
+ return exception;
} catch (Throwable e) {
- LOG.trace("Unable to wrap exception of type {}: it has no (String) "
- + "constructor", clazz, e);
throw exception;
}
}
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestIPC.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestIPC.java
index 1c1ad00..1921a35 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestIPC.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestIPC.java
@@ -1582,11 +1582,10 @@ public class TestIPC {
try {
call(client, 0, addr, conf);
} catch (IOException ioe) {
- Throwable t = ioe.getCause();
- Assert.assertNotNull(t);
- Assert.assertEquals(RpcException.class, t.getClass());
+ Assert.assertNotNull(ioe);
+ Assert.assertEquals(RpcException.class, ioe.getClass());
Assert.assertEquals("RPC response exceeds maximum data length",
- t.getMessage());
+ ioe.getMessage());
return;
}
Assert.fail("didn't get limit exceeded");
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestNetUtils.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestNetUtils.java
index 62bd1b1..b11b1e9 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestNetUtils.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestNetUtils.java
@@ -279,11 +279,9 @@ public class TestNetUtils {
@Test
public void testWrapIOEWithNoStringConstructor() throws Throwable {
IOException e = new CharacterCodingException();
- IOException wrapped = verifyExceptionClass(e, IOException.class);
- assertInException(wrapped, "Failed on local exception");
- assertNotInException(wrapped, NetUtils.HADOOP_WIKI);
- assertInException(wrapped, "Host Details ");
- assertRemoteDetailsIncluded(wrapped);
+ IOException wrapped =
+ verifyExceptionClass(e, CharacterCodingException.class);
+ assertEquals(null, wrapped.getMessage());
}
@Test
@@ -295,11 +293,8 @@ public class TestNetUtils {
}
}
IOException e = new TestIOException();
- IOException wrapped = verifyExceptionClass(e, IOException.class);
- assertInException(wrapped, "Failed on local exception");
- assertNotInException(wrapped, NetUtils.HADOOP_WIKI);
- assertInException(wrapped, "Host Details ");
- assertRemoteDetailsIncluded(wrapped);
+ IOException wrapped = verifyExceptionClass(e, TestIOException.class);
+ assertEquals(null, wrapped.getMessage());
}
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org