meszibalu commented on a change in pull request #4125:
URL: https://github.com/apache/hbase/pull/4125#discussion_r831924215
##########
File path:
hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcConnection.java
##########
@@ -321,14 +319,25 @@ public void run(boolean cancelled) throws IOException {
if (cancelled) {
setCancelled(call);
} else {
+ Channel channel = channelRef.get();
if (channel == null) {
- connect();
+ try {
+ Channel newChannel = connect();
+ if (!channelRef.compareAndSet(null, newChannel)) {
+ newChannel.close();
+ }
+ channel = channelRef.get();
Review comment:
What prevents `channel` from becoming `null` at this point again? An
`AtomicBoolean` for connecting would be better in my opinion.
##########
File path:
hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcConnection.java
##########
@@ -114,47 +107,43 @@
@Override
protected void callTimeout(Call call) {
- execute(eventLoop, () -> {
- if (channel != null) {
- channel.pipeline().fireUserEventTriggered(new CallEvent(TIMEOUT,
call));
- }
- });
+ Channel channel = channelRef.get();
+ if (channel != null) {
+ channel.pipeline().fireUserEventTriggered(new CallEvent(TIMEOUT, call));
+ }
}
@Override
public boolean isActive() {
- return channel != null;
+ return channelRef.get() != null;
}
private void shutdown0() {
- assert eventLoop.inEventLoop();
+ Channel channel = channelRef.get();
if (channel != null) {
channel.close();
- channel = null;
+ channelRef.compareAndSet(channel, null);
Review comment:
This is not good. I would do this:
```
Channel channel = channelRef.getAndSet(null);
if (channel != null) {
// close
}
```
--
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]