From e604eec3f71d77cf28c5db82dbf22d90bc5e529d Mon Sep 17 00:00:00 2001 From: Andrew Purtell Date: Thu, 4 Jan 2018 15:57:32 -0800 Subject: [PATCH] HBASE-19708 Avoid NPE when the RPC listener's accept channel is closed --- .../src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java index 3000622014..bc3b33ad7e 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java @@ -206,6 +206,7 @@ public class RpcServer implements RpcServerInterface, ConfigurationObserver { protected final InetSocketAddress bindAddress; protected int port; // port we listen on + protected InetSocketAddress address; // inet address we listen on private int readThreads; // number of read threads protected int maxIdleTime; // the maximum idle time after // which a client may be @@ -657,6 +658,8 @@ public class RpcServer implements RpcServerInterface, ConfigurationObserver { // Bind the server socket to the binding addrees (can be different from the default interface) bind(acceptChannel.socket(), bindAddress, backlogLength); port = acceptChannel.socket().getLocalPort(); //Could be an ephemeral port + address = (InetSocketAddress)acceptChannel.socket().getLocalSocketAddress(); + // create a selector; selector= Selector.open(); @@ -888,7 +891,7 @@ public class RpcServer implements RpcServerInterface, ConfigurationObserver { } InetSocketAddress getAddress() { - return (InetSocketAddress)acceptChannel.socket().getLocalSocketAddress(); + return address; } void doAccept(SelectionKey key) throws IOException, OutOfMemoryError { @@ -2197,7 +2200,6 @@ public class RpcServer implements RpcServerInterface, ConfigurationObserver { this.cellBlockBuilder = new CellBlockBuilder(conf); - // Create the responder here responder = new Responder(); this.authorize = conf.getBoolean(HADOOP_SECURITY_AUTHORIZATION, false); -- 2.15.1