This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/main by this push:
     new 3dd50f8ff1 ARTEMIS-3831 scale-down w/jgroups fails if using same dg as 
cluster-connection
3dd50f8ff1 is described below

commit 3dd50f8ff14116234909ad2e275515b2b83971b5
Author: Justin Bertram <[email protected]>
AuthorDate: Wed Jan 10 21:56:51 2024 -0600

    ARTEMIS-3831 scale-down w/jgroups fails if using same dg as 
cluster-connection
    
    If both scale-down and cluster-connection are using the same JGroups
    discovery-group then when the cluster-connection stops it will close the
    underlying org.jgroups.JChannel and when the scale-down process tries to
    use it to find a server it will fail.
    
    This commit ensures that the JGroupsBroadcastEndpoint implementation of
    BroadcastEndpoint#openClient initializes the channel if it has been
    closed.
---
 .../activemq/artemis/api/core/JGroupsBroadcastEndpoint.java      | 3 +++
 .../artemis/tests/integration/discovery/DiscoveryTest.java       | 9 +++++++++
 2 files changed, 12 insertions(+)

diff --git 
a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsBroadcastEndpoint.java
 
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsBroadcastEndpoint.java
index 75ce007240..323a598c5e 100644
--- 
a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsBroadcastEndpoint.java
+++ 
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsBroadcastEndpoint.java
@@ -96,6 +96,9 @@ public abstract class JGroupsBroadcastEndpoint implements 
BroadcastEndpoint {
       if (clientOpened) {
          return;
       }
+      if (channel.getChannel() == null || channel.getChannel().isClosed()) {
+         initChannel();
+      }
       internalOpen();
       receiver = new JGroupsReceiver();
       channel.addReceiver(receiver);
diff --git 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryTest.java
 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryTest.java
index c53f11f4f3..08a869abc9 100644
--- 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryTest.java
+++ 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryTest.java
@@ -140,6 +140,15 @@ public class DiscoveryTest extends DiscoveryBaseTest {
       assertEqualsDiscoveryEntries(Arrays.asList(live1), entries);
    }
 
+   @Test
+   public void testJGroupsOpenClientInitializesChannel() throws Exception {
+      JGroupsFileBroadcastEndpointFactory factory = new 
JGroupsFileBroadcastEndpointFactory().setFile(TEST_JGROUPS_CONF_FILE).setChannelName("tst");
+      BroadcastEndpoint endpoint = factory.createBroadcastEndpoint();
+      endpoint.close(false);
+      endpoint.openClient();
+      endpoint.close(false);
+   }
+
    /**
     * Create one broadcaster and 100 receivers. Make sure broadcasting works.
     * Then stop 99 of the receivers, the last one could still be working.

Reply via email to