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 aa...@apache.org on 2019/01/22 01:20:14 UTC
[hadoop] branch trunk updated: HADOOP-15787. [JDK11]
TestIPC.testRTEDuringConnectionSetup fails. Contributed by Zsolt Venczel.
This is an automated email from the ASF dual-hosted git repository.
aajisaka 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 a463cf7 HADOOP-15787. [JDK11] TestIPC.testRTEDuringConnectionSetup fails. Contributed by Zsolt Venczel.
a463cf7 is described below
commit a463cf75a0ab1f0dbb8cfa16c39a4e698bc1a625
Author: Akira Ajisaka <aa...@apache.org>
AuthorDate: Tue Jan 22 10:19:05 2019 +0900
HADOOP-15787. [JDK11] TestIPC.testRTEDuringConnectionSetup fails. Contributed by Zsolt Venczel.
---
.../src/test/java/org/apache/hadoop/ipc/TestIPC.java | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
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 7ba4e53..6d2f9c7 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
@@ -23,7 +23,6 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
@@ -642,6 +641,16 @@ public class TestIPC {
}
/**
+ * Mock socket class to help inject an exception for HADOOP-7428.
+ */
+ static class MockSocket extends Socket {
+ @Override
+ public synchronized void setSoTimeout(int timeout) {
+ throw new RuntimeException("Injected fault");
+ }
+ }
+
+ /**
* Test that, if a RuntimeException is thrown after creating a socket
* but before successfully connecting to the IPC server, that the
* failure is handled properly. This is a regression test for
@@ -654,11 +663,8 @@ public class TestIPC {
SocketFactory spyFactory = spy(NetUtils.getDefaultSocketFactory(conf));
Mockito.doAnswer(new Answer<Socket>() {
@Override
- public Socket answer(InvocationOnMock invocation) throws Throwable {
- Socket s = spy((Socket)invocation.callRealMethod());
- doThrow(new RuntimeException("Injected fault")).when(s)
- .setSoTimeout(anyInt());
- return s;
+ public Socket answer(InvocationOnMock invocation) {
+ return new MockSocket();
}
}).when(spyFactory).createSocket();
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org