This is an automated email from the ASF dual-hosted git repository.

ayushsaxena 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 aeae571  Revert "HADOOP-18024. SocketChannel is not closed when 
IOException happens in Server$Listener.doAccept (#3719)"
aeae571 is described below

commit aeae5716cc20251cd945c823122911f235e8fd6b
Author: Ayush Saxena <[email protected]>
AuthorDate: Tue Feb 1 11:00:54 2022 +0530

    Revert "HADOOP-18024. SocketChannel is not closed when IOException happens 
in Server$Listener.doAccept (#3719)"
    
    This reverts commit 6ed01585eb1929497efbafe2f19bda4f1a56575c.
    
    Breaks TestIPC#testIOEOnListenerAccept
---
 .../main/java/org/apache/hadoop/ipc/Server.java    | 25 ++----------
 .../test/java/org/apache/hadoop/ipc/TestIPC.java   | 47 ----------------------
 2 files changed, 4 insertions(+), 68 deletions(-)

diff --git 
a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java
 
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java
index 41afb6e..c5732c6 100644
--- 
a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java
+++ 
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java
@@ -1329,14 +1329,6 @@ public abstract class Server {
     }
   }
 
-  @VisibleForTesting
-  @InterfaceAudience.Private
-  protected void configureSocketChannel(SocketChannel channel) throws 
IOException {
-    channel.configureBlocking(false);
-    channel.socket().setTcpNoDelay(tcpNoDelay);
-    channel.socket().setKeepAlive(true);
-  }
-
   /** Listens on the socket. Creates jobs for the handler threads*/
   private class Listener extends Thread {
     
@@ -1543,24 +1535,15 @@ public abstract class Server {
     InetSocketAddress getAddress() {
       return (InetSocketAddress)acceptChannel.socket().getLocalSocketAddress();
     }
-
+    
     void doAccept(SelectionKey key) throws InterruptedException, IOException,  
OutOfMemoryError {
       ServerSocketChannel server = (ServerSocketChannel) key.channel();
       SocketChannel channel;
       while ((channel = server.accept()) != null) {
 
-        try {
-          configureSocketChannel(channel);
-        } catch (IOException e) {
-          LOG.warn("Error in an accepted SocketChannel", e);
-          try {
-            channel.socket().close();
-            channel.close();
-          } catch (IOException ex) {
-            LOG.warn("Error in closing SocketChannel", ex);
-          }
-          continue;
-        }
+        channel.configureBlocking(false);
+        channel.socket().setTcpNoDelay(tcpNoDelay);
+        channel.socket().setKeepAlive(true);
         
         Reader reader = getReader();
         Connection c = connectionManager.register(channel,
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 90415b4..95ff302 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
@@ -34,7 +34,6 @@ import static org.mockito.Mockito.verify;
 import java.io.ByteArrayOutputStream;
 import java.io.DataInput;
 import java.io.DataOutput;
-import java.io.EOFException;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
@@ -49,7 +48,6 @@ import java.net.SocketAddress;
 import java.net.SocketException;
 import java.net.SocketTimeoutException;
 import java.net.UnknownHostException;
-import java.nio.channels.SocketChannel;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
@@ -618,51 +616,6 @@ public class TestIPC {
       WRITABLE_FAULTS_SLEEP = 0;
     }
   }
-
-  /**
-   * Test for HADOOP-18024.
-   */
-  @Test(timeout=60000)
-  public void testIOEOnListenerAccept() throws Exception {
-    // start server
-    Server server = new TestServer(1, false,
-            LongWritable.class, LongWritable.class) {
-      @Override
-      protected void configureSocketChannel(SocketChannel channel) throws 
IOException {
-        maybeThrowIOE();
-        super.configureSocketChannel(channel);
-      }
-    };
-    InetSocketAddress addr = NetUtils.getConnectAddress(server);
-    server.start();
-
-    // start client
-    WRITABLE_FAULTS_ENABLED = true;
-    Client client = new Client(LongWritable.class, conf);
-    try {
-      LongWritable param = LongWritable.class.newInstance();
-
-      try {
-        call(client, param, addr, 0, conf);
-        fail("Expected an exception to have been thrown");
-      } catch (EOFException e) {
-        LOG.info("Got expected exception", e);
-      } catch (Throwable t) {
-        LOG.warn("Got unexpected error", t);
-        fail("Expected an EOFException to have been thrown");
-      }
-
-      // Doing a second call with faults disabled should return fine --
-      // ie the internal state of the client or server should not be broken
-      // by the failed call
-      WRITABLE_FAULTS_ENABLED = false;
-      call(client, param, addr, 0, conf);
-
-    } finally {
-      client.stop();
-      server.stop();
-    }
-  }
   
   private static void assertExceptionContains(
       Throwable t, String substring) {

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to