meszibalu commented on a change in pull request #4125:
URL: https://github.com/apache/hbase/pull/4125#discussion_r835140899



##########
File path: 
hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcConnection.java
##########
@@ -321,31 +320,39 @@ public void run(boolean cancelled) throws IOException {
         } else {
           Channel channel = channelRef.get();
           if (channel == null) {
-            try {
-              Channel newChannel = connect();
-              if (!channelRef.compareAndSet(null, newChannel)) {
-                newChannel.close();
+            connect().addListener(new ChannelFutureListener() {
+              @Override public void operationComplete(ChannelFuture 
channelFuture) {
+                Channel ch = channelFuture.channel();

Review comment:
       Ok, let me rephrase this: won't `channelFuture.channel()` throw an 
exception? You call it, but you don't use the returned channel when the future 
is not successful.

##########
File path: 
hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcConnection.java
##########
@@ -321,31 +320,39 @@ public void run(boolean cancelled) throws IOException {
         } else {
           Channel channel = channelRef.get();
           if (channel == null) {
-            try {
-              Channel newChannel = connect();
-              if (!channelRef.compareAndSet(null, newChannel)) {
-                newChannel.close();
+            connect().addListener(new ChannelFutureListener() {
+              @Override public void operationComplete(ChannelFuture 
channelFuture) {
+                Channel ch = channelFuture.channel();
+                if (channelFuture.isSuccess()) {
+                  if (!channelRef.compareAndSet(null, ch)) {
+                    ch.close();
+                    ch = channelRef.get();
+                  }
+                  writeAndFlushToChannel(call, ch);

Review comment:
       If there is a concurrent shutdown, `ch = channelRef.get()` might return 
`null`, so you call `writeAndFlushToChannel` with `null` channel. That should 
be avoided.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to