You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by "gtully (via GitHub)" <gi...@apache.org> on 2025/10/03 19:21:40 UTC

[PR] ARTEMIS-5693 ensure channel manager does not return a closing clannel… [activemq-artemis]

gtully opened a new pull request, #5953:
URL: https://github.com/apache/activemq-artemis/pull/5953

   … wrapper


-- 
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: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact



Re: [PR] ARTEMIS-5693 ensure channel manager does not return a closing clannel… [activemq-artemis]

Posted by "gtully (via GitHub)" <gi...@apache.org>.
gtully commented on code in PR #5953:
URL: https://github.com/apache/activemq-artemis/pull/5953#discussion_r2405575753


##########
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/broadcast/JGroupsBroadcastTest.java:
##########
@@ -107,4 +118,102 @@ public void testRefCount() throws Exception {
       }
    }
 
-}
+
+   @Test
+   public void testConcurrentAccess() throws Exception {
+
+      final CountDownLatch inClose = new CountDownLatch(1);
+      final CountDownLatch doClose = new CountDownLatch(1);
+
+      final Deque<Throwable> errors = new ConcurrentLinkedDeque<>();
+
+      class InstrumentedJChannel extends JChannel {
+         final AtomicBoolean closed = new AtomicBoolean(false);
+
+         InstrumentedJChannel() throws Exception {
+         }
+
+         @Override
+         public synchronized void close() {
+            closed.set(true);
+            inClose.countDown();
+            try {
+               doClose.await(100, TimeUnit.MILLISECONDS);
+            } catch (InterruptedException e) {
+               throw new RuntimeException(e);
+            }
+         }
+
+         @Override
+         public synchronized JChannel connect(String cluster_name) throws Exception {
+            if (closed.get()) {
+               throw new IllegalStateException("closed");
+            }
+            return this;
+         }
+
+         @Override
+         public boolean isConnected() {
+            return !closed.get();
+         }
+      }
+
+      AtomicInteger numChannels = new AtomicInteger(0);
+      class JGroupsBroadcastEndpointWithChannel extends JGroupsBroadcastEndpoint {
+         JGroupsBroadcastEndpointWithChannel() {
+            super(JChannelManager.getInstance(), "shared");
+         }
+
+         @Override
+         public JChannel createChannel() throws Exception {
+            numChannels.incrementAndGet();
+            return new InstrumentedJChannel();
+         }
+      }
+
+      ExecutorService executor = Executors.newFixedThreadPool(2);

Review Comment:
   good idea, thanks.



-- 
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: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact



Re: [PR] ARTEMIS-5693 ensure channel manager does not return a closing clannel… [activemq-artemis]

Posted by "tabish121 (via GitHub)" <gi...@apache.org>.
tabish121 commented on code in PR #5953:
URL: https://github.com/apache/activemq-artemis/pull/5953#discussion_r2403246203


##########
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/broadcast/JGroupsBroadcastTest.java:
##########
@@ -107,4 +118,102 @@ public void testRefCount() throws Exception {
       }
    }
 
-}
+
+   @Test
+   public void testConcurrentAccess() throws Exception {
+
+      final CountDownLatch inClose = new CountDownLatch(1);
+      final CountDownLatch doClose = new CountDownLatch(1);
+
+      final Deque<Throwable> errors = new ConcurrentLinkedDeque<>();
+
+      class InstrumentedJChannel extends JChannel {
+         final AtomicBoolean closed = new AtomicBoolean(false);
+
+         InstrumentedJChannel() throws Exception {
+         }
+
+         @Override
+         public synchronized void close() {
+            closed.set(true);
+            inClose.countDown();
+            try {
+               doClose.await(100, TimeUnit.MILLISECONDS);
+            } catch (InterruptedException e) {
+               throw new RuntimeException(e);
+            }
+         }
+
+         @Override
+         public synchronized JChannel connect(String cluster_name) throws Exception {
+            if (closed.get()) {
+               throw new IllegalStateException("closed");
+            }
+            return this;
+         }
+
+         @Override
+         public boolean isConnected() {
+            return !closed.get();
+         }
+      }
+
+      AtomicInteger numChannels = new AtomicInteger(0);
+      class JGroupsBroadcastEndpointWithChannel extends JGroupsBroadcastEndpoint {
+         JGroupsBroadcastEndpointWithChannel() {
+            super(JChannelManager.getInstance(), "shared");
+         }
+
+         @Override
+         public JChannel createChannel() throws Exception {
+            numChannels.incrementAndGet();
+            return new InstrumentedJChannel();
+         }
+      }
+
+      ExecutorService executor = Executors.newFixedThreadPool(2);

Review Comment:
   You could probably add a shutdown directive using runAfter(...) as other tests do



-- 
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: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact



Re: [PR] ARTEMIS-5693 ensure channel manager does not return a closing clannel… [activemq-artemis]

Posted by "tabish121 (via GitHub)" <gi...@apache.org>.
tabish121 merged PR #5953:
URL: https://github.com/apache/activemq-artemis/pull/5953


-- 
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: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact