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 ki...@apache.org on 2020/02/05 19:48:50 UTC
[hadoop] branch branch-2.8 updated: HADOOP-15787.
TestIPC.testRTEDuringConnectionSetup fails with jdk8u242. Contributed by
Zsolt Venczel.
This is an automated email from the ASF dual-hosted git repository.
kihwal pushed a commit to branch branch-2.8
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/branch-2.8 by this push:
new c5cc75a HADOOP-15787. TestIPC.testRTEDuringConnectionSetup fails with jdk8u242. Contributed by Zsolt Venczel.
c5cc75a is described below
commit c5cc75a8550d5600b0f7d516d3c3490870b8847b
Author: Kihwal Lee <ki...@apache.org>
AuthorDate: Wed Feb 5 13:48:32 2020 -0600
HADOOP-15787. TestIPC.testRTEDuringConnectionSetup fails with jdk8u242. Contributed by Zsolt Venczel.
(cherry picked from commit a463cf75a0ab1f0dbb8cfa16c39a4e698bc1a625)
(cherry picked from commit 0b19c8e0860bf558d995951ab9ac4cd8a1674759)
Conflicts:
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestIPC.java
---
.../src/test/java/org/apache/hadoop/ipc/TestIPC.java | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 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 61e1d8c..d28d95b 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
@@ -24,6 +24,7 @@ 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;
import static org.mockito.Mockito.spy;
@@ -592,6 +593,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
@@ -604,11 +615,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