szetszwo commented on code in PR #955:
URL: https://github.com/apache/ratis/pull/955#discussion_r1376582942
##########
ratis-netty/src/main/java/org/apache/ratis/netty/client/NettyClientStreamRpc.java:
##########
@@ -78,7 +80,33 @@ public class NettyClientStreamRpc implements
DataStreamClientRpc {
public static final Logger LOG =
LoggerFactory.getLogger(NettyClientStreamRpc.class);
private static class WorkerGroupGetter implements Supplier<EventLoopGroup> {
- private static final AtomicReference<EventLoopGroup> SHARED_WORKER_GROUP =
new AtomicReference<>();
+
+ private static final
AtomicReference<ReferenceCountedObject<EventLoopGroup>> SHARED_WORKER_GROUP =
+ new AtomicReference<>();
Review Comment:
Yes. When there are two or more threads changing an `AtomicReference` at
the same time, the `updateAndGet(..)` method runs in a loop and may call the
update function multiple times. In our previous code, it may create multiple
`EventLoopGroup` objects and the old objects will not be shutdown.
--
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]