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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact