You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by GitBox <gi...@apache.org> on 2019/03/13 16:13:44 UTC

[GitHub] [activemq-artemis] michaelandrepearce commented on a change in pull request #2558: ARTEMIS-2257 Race condition when calling shutdownGracefully in SharedEventLoopGroup

michaelandrepearce commented on a change in pull request #2558: ARTEMIS-2257 Race condition when calling shutdownGracefully in SharedEventLoopGroup
URL: https://github.com/apache/activemq-artemis/pull/2558#discussion_r265210254
 
 

 ##########
 File path: artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/SharedEventLoopGroup.java
 ##########
 @@ -84,30 +84,32 @@ public ThreadFactory run() {
 
    @Override
    public Future<?> shutdownGracefully(final long l, final long l2, final TimeUnit timeUnit) {
-      if (channelFactoryCount.decrementAndGet() == 0) {
-         shutdown.compareAndSet(null, next().scheduleAtFixedRate(new Runnable() {
-            @Override
-            public void run() {
-               synchronized (SharedEventLoopGroup.class) {
-                  if (shutdown.get() != null) {
-                     Future<?> future = SharedEventLoopGroup.super.shutdownGracefully(l, l2, timeUnit);
-                     future.addListener(new FutureListener<Object>() {
-                        @Override
-                        public void operationComplete(Future<Object> future) throws Exception {
-                           if (future.isSuccess()) {
-                              terminationPromise.setSuccess(null);
-                           } else {
-                              terminationPromise.setFailure(future.cause());
+      synchronized (SharedEventLoopGroup.class) {
 
 Review comment:
   Thats a good point there is risk especially where you may run two seperate clients to different brokers or have multiple embedded brokers. Sync on class or static sharing isnt always safe 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services