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

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


The following commit(s) were added to refs/heads/main by this push:
     new 9eb84c56c6 Use of GitHub Actions, and enable dependabot (#1497)
9eb84c56c6 is described below

commit 9eb84c56c683576acb94b6b0ca35ad2b147cca53
Author: JB Onofré <[email protected]>
AuthorDate: Sat Jan 10 06:14:08 2026 +0100

    Use of GitHub Actions, and enable dependabot (#1497)
    
    * Use of GitHub Actions, and enable dependabot
    Keep a backup of Jenkinsfile for now
    
    * Include push/PR on activemq-6.1.x and activemq-5.19.x branches
    
    * Add new runners for the build
    
    * Set Java distribution
    
    * Remove surefire rerun options as deprecated
    
    * Removing JDK 24 for now as the tests will fail due to the SecurityManager
    
    * Remove JDK 21 as the tests will fail due to SecurityManager
    
    * Use separated jobs for build and test (to use different JDK matrix)
    Re-add -Dsurefire.rerunFailingTestsCount=3 option to tests
    
    * Update right GitHub Action syntax for options
    
    * Re-add Jenkinsfile with daily schedule, building only on s390x and 
including Sonar stage
    
    * Fix surefire argLine and set memory configuration
    
    * Temporary ignore JournalCorruptionEofIndexRecoveryTest to test the GitHub 
Action CI
    
    * Remove heap memory setting and renable KahaDB test
    
    * Clear separation between development cycle and nightly full check
    
    * Adding logs to trigger a new build
    
    * Revert latest for OS versions
    
    * Do not leak connections while constantly checking if the new connection 
is different from the failed one
    
    * Avoid race conditions by waiting for the log before creating the second 
consumer.
    
    * [AMQ-9820]: closed connections leaking into the pool when 
reconnectOnException is used
    
    * try to avoid failures when stats are not fully synchronized
    
    * Increase the timeout to allow statistics to sync up
    
    * switch the latch and the counter, to make sure we wait before asserting 
the values bellow
    
    * See if we can better fix the ConnectionPool
    
    * Add all platforms for on-demand Jenkins
    
    ---------
    
    Co-authored-by: Jean-Louis Monteiro <[email protected]>
---
 .asf.yaml                                          |  26 ++-
 .github/dependabot.yml                             |  36 ++++
 .github/workflows/ci-nightly.yml                   |  69 +++++++
 .github/workflows/ci-quick.yml                     |  66 ++++++
 .github/workflows/deploy.yml                       |  42 ++++
 Jenkinsfile                                        |   6 +-
 .../apache/activemq/jms/pool/ConnectionPool.java   |   2 +
 .../activemq/jms/pool/PooledConnectionFactory.java |   7 +-
 .../PooledConnectionSecurityExceptionTest.java     | 227 ++++++++-------------
 .../JournalCorruptionEofIndexRecoveryTest.java     |   2 +-
 .../jms2/ActiveMQJMS2MessageListenerTest.java      |   2 +-
 .../network/NetworkAdvancedStatisticsTest.java     |  10 +-
 .../usecases/UsageBlockedDispatchTest.java         |   3 +
 pom.xml                                            |   3 +-
 14 files changed, 344 insertions(+), 157 deletions(-)

diff --git a/.asf.yaml b/.asf.yaml
index 8c334b1714..ff4712e1fa 100644
--- a/.asf.yaml
+++ b/.asf.yaml
@@ -29,12 +29,34 @@ github:
     - stomp
     - java
     - jms
+
   enabled_merge_buttons:
     squash: true
-    merge: true
-    rebase: true
+    merge: false
+    rebase: false
+
+  del_branch_on_merge: true
+
+  protected_branches:
+    main:
+      required_pull_request_reviews:
+        require_code_owner_reviews: false
+        required_approving_review_count: 0
+      required_linear_history: true
+      required_status_checks:
+        strict: false
+        contexts:
+          - build
+          - test
+
+  features:
+    wiki: false
+    issues: false
+    projects: false
+
   autolink_jira:
     - AMQ
+
 notifications:
   commits: [email protected]
   issues: [email protected]
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000000..686695e99a
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,36 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+version: 2
+updates:
+  - package-ecosystem: "github-actions"
+    directory: "/"
+    schedule:
+      interval: "daily"
+    ignore:
+      - dependency-name: "*"
+        update-types: ["version-update:semver-major"]
+  - package-ecosystem: "maven"
+    directory: "/"
+    schedule:
+      interval: "daily"
+    open-pull-requests-limit: 50
+    ignore:
+      - dependency-name: "*"
+        update-types: ["version-update:semver-major"]
diff --git a/.github/workflows/ci-nightly.yml b/.github/workflows/ci-nightly.yml
new file mode 100644
index 0000000000..db29edce9e
--- /dev/null
+++ b/.github/workflows/ci-nightly.yml
@@ -0,0 +1,69 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: CI Nightly
+
+on:
+  schedule:
+    - cron: '0 3 * * *'
+
+jobs:
+  build:
+
+    permissions:
+      contents: read
+
+    strategy:
+      matrix:
+        os: [ ubuntu-24.04, ubuntu-22.04, macos-26, macos-15, windows-2025, 
windows-2022 ]
+        java-version: [ 17, 21, 24 ]
+
+    runs-on: ${{ matrix.os }}
+
+    steps:
+      - uses: actions/checkout@v4
+      - name: Set up JDK
+        uses: actions/setup-java@v4
+        with:
+          java-version: ${{ matrix.java-version }}
+          distribution: temurin
+      - name: Build
+        run: mvn -U -B -e clean install -DskipTests
+      - name: Verify
+        run: mvn apache-rat:check
+
+  test:
+
+    permissions:
+      contents: read
+
+    strategy:
+      matrix:
+        os: [ ubuntu-24.04, ubuntu-22.04, macos-26, macos-15, windows-2025, 
windows-2022 ]
+        java-version: [ 17, 21, 24 ]
+
+    runs-on: ${{ matrix.os }}
+
+    steps:
+      - uses: actions/checkout@v4
+      - name: Set up JDK
+        uses: actions/setup-java@v4
+        with:
+          java-version: ${{ matrix.java-version }}
+          distribution: temurin
+      - name: Test
+        run: mvn -B -e -fae test
diff --git a/.github/workflows/ci-quick.yml b/.github/workflows/ci-quick.yml
new file mode 100644
index 0000000000..4fbd7fdabe
--- /dev/null
+++ b/.github/workflows/ci-quick.yml
@@ -0,0 +1,66 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: CI Quick
+
+on:
+  push:
+    branches: [ "main", "activemq-6.1.x", "activemq-5.19.x" ]
+  pull_request:
+    branches: [ "main", "activemq-6.1.x", "activemq-5.19.x" ]
+
+jobs:
+  build:
+
+    permissions:
+      contents: read
+
+    strategy:
+      matrix:
+        os: [ ubuntu-24.04, macos-26, windows-2025 ]
+        java-version: [ 17, 21 ]
+
+    runs-on: ${{ matrix.os }}
+
+    steps:
+      - uses: actions/checkout@v4
+      - name: Set up JDK
+        uses: actions/setup-java@v4
+        with:
+          java-version: ${{ matrix.java-version }}
+          distribution: temurin
+      - name: Build
+        run: mvn -U -B -e clean install -DskipTests
+      - name: Verify
+        run: mvn apache-rat:check
+
+  test:
+
+    permissions:
+      contents: read
+
+    runs-on: ubuntu-24.04
+
+    steps:
+      - uses: actions/checkout@v4
+      - name: Set up JDK
+        uses: actions/setup-java@v4
+        with:
+          java-version: 17
+          distribution: temurin
+      - name: Test
+        run: mvn -B -e -fae test
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
new file mode 100644
index 0000000000..253277c6c9
--- /dev/null
+++ b/.github/workflows/deploy.yml
@@ -0,0 +1,42 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+name: Deploy
+
+on:
+  schedule:
+    - cron: '0 0 * * *'
+
+jobs:
+  deploy:
+
+    permissions:
+      contents: read
+
+    runs-on: ubuntu-24.04
+
+    steps:
+      - uses: actions/checkout@v4
+      - name: Set up JDK 
+        uses: actions/setup-java@v4
+        with:
+          java-version: 17
+          distribution: temurin
+      - name: Deploy
+        run: mvn -B -e deploy -Pdeploy -DskipTests
diff --git a/Jenkinsfile b/Jenkinsfile
index 94a8c7a772..95fb388301 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -27,6 +27,10 @@ pipeline {
         }
     }
 
+    triggers {
+      cron('0 0 * * *')
+    }
+
     tools {
         // ... tell Jenkins what java version, maven version or other tools 
are required ...
         maven 'maven_3_latest'
@@ -42,7 +46,7 @@ pipeline {
     }
 
     parameters {
-        choice(name: 'nodeLabel', choices: ['ubuntu', 's390x', 'arm', 
'Windows']) 
+        choice(name: 'nodeLabel', choices: [ 'ubuntu', 's390x', 'arm', 
'Windows' ]) 
         choice(name: 'jdkVersion', choices: ['jdk_17_latest', 'jdk_21_latest', 
'jdk_24_latest', 'jdk_17_latest_windows', 'jdk_21_latest_windows', 
'jdk_24_latest_windows'])
         booleanParam(name: 'deployEnabled', defaultValue: false)
         booleanParam(name: 'parallelTestsEnabled', defaultValue: true)
diff --git 
a/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/ConnectionPool.java
 
b/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/ConnectionPool.java
index b9830d3954..6b8754beea 100644
--- 
a/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/ConnectionPool.java
+++ 
b/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/ConnectionPool.java
@@ -125,6 +125,7 @@ public class ConnectionPool implements ExceptionListener {
                 connection.start();
             } catch (JMSException e) {
                 started.set(false);
+                setHasExpired(true);
                 if (isReconnectOnException()) {
                     close();
                 }
@@ -377,6 +378,7 @@ public class ConnectionPool implements ExceptionListener {
 
     @Override
     public void onException(JMSException exception) {
+        setHasExpired(true);
         if (isReconnectOnException()) {
             close();
         }
diff --git 
a/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/PooledConnectionFactory.java
 
b/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/PooledConnectionFactory.java
index 1b11531b45..d3a64e1934 100644
--- 
a/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/PooledConnectionFactory.java
+++ 
b/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/PooledConnectionFactory.java
@@ -129,12 +129,7 @@ public class PooledConnectionFactory implements 
ConnectionFactory, QueueConnecti
                     @Override
                     public boolean validateObject(ConnectionKey connectionKey, 
PooledObject<ConnectionPool> pooledObject) {
                         ConnectionPool connection = pooledObject.getObject();
-                        if (connection == null || connection.getConnection() 
== null) {
-                            LOG.trace("Connection has been closed and will be 
destroyed: {}", connection);
-                            return false;
-                        }
-
-                        if (connection.expiredCheck()) {
+                        if (connection != null && connection.expiredCheck()) {
                             LOG.trace("Connection has expired: {} and will be 
destroyed", connection);
                             return false;
                         }
diff --git 
a/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionSecurityExceptionTest.java
 
b/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionSecurityExceptionTest.java
index 445f40feb3..70809f754f 100644
--- 
a/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionSecurityExceptionTest.java
+++ 
b/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionSecurityExceptionTest.java
@@ -44,8 +44,11 @@ import org.slf4j.LoggerFactory;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.CountDownLatch;
 
 import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -65,47 +68,42 @@ public class PooledConnectionSecurityExceptionTest {
 
     @Test
     public void testFailedConnectThenSucceeds() throws JMSException {
-        Connection connection = pooledConnFact.createConnection("invalid", 
"credentials");
+        try (final Connection connection1 = 
pooledConnFact.createConnection("invalid", "credentials")) {
+            assertThrows(JMSSecurityException.class, connection1::start);
 
-        try {
-            connection.start();
-            fail("Should fail to connect");
-        } catch (JMSSecurityException ex) {
-            LOG.info("Caught expected security error");
-        }
-
-        connection = pooledConnFact.createConnection("system", "manager");
-        connection.start();
+            try (final Connection connection2 = 
pooledConnFact.createConnection("system", "manager")) {
+                connection2.start();
 
-        LOG.info("Successfully create new connection.");
+            } catch (final JMSSecurityException ex) {
+                fail("Should have succeeded to connect on 2nd attempt");
+            }
 
-        connection.close();
+        }
     }
 
     @Test
-    public void testFailedConnectThenSucceedsWithListener() throws 
JMSException {
-        Connection connection = pooledConnFact.createConnection("invalid", 
"credentials");
-        connection.setExceptionListener(new ExceptionListener() {
+    public void testFailedConnectThenSucceedsWithListener() throws 
JMSException, InterruptedException {
+        final CountDownLatch onExceptionCalled = new CountDownLatch(1);
+        try (final Connection connection1 = 
pooledConnFact.createConnection("invalid", "credentials")) {
+            connection1.setExceptionListener(new ExceptionListener() {
+
+                @Override
+                public void onException(JMSException exception) {
+                    LOG.warn("Connection get error: {}", 
exception.getMessage());
+                    onExceptionCalled.countDown();
+                }
+            });
+            assertThrows(JMSSecurityException.class, connection1::start);
+
+            try (final Connection connection2 = 
pooledConnFact.createConnection("system", "manager")) {
+                connection2.start();
 
-            @Override
-            public void onException(JMSException exception) {
-                LOG.warn("Connection get error: {}", exception.getMessage());
+            } catch (final JMSSecurityException ex) {
+                fail("Should have succeeded to connect on 2nd attempt");
             }
-        });
 
-        try {
-            connection.start();
-            fail("Should fail to connect");
-        } catch (JMSSecurityException ex) {
-            LOG.info("Caught expected security error");
         }
-
-        connection = pooledConnFact.createConnection("system", "manager");
-        connection.start();
-
-        LOG.info("Successfully create new connection.");
-
-        connection.close();
+        assertTrue("onException called", onExceptionCalled.await(10, 
java.util.concurrent.TimeUnit.SECONDS));
     }
 
     @Test
@@ -119,65 +117,41 @@ public class PooledConnectionSecurityExceptionTest {
     public void testFailureGetsNewConnectionOnRetry() throws Exception {
         pooledConnFact.setMaxConnections(1);
 
-        final PooledConnection connection1 = (PooledConnection) 
pooledConnFact.createConnection("invalid", "credentials");
-
-        try {
-            connection1.start();
-            fail("Should fail to connect");
-        } catch (JMSSecurityException ex) {
-            LOG.info("Caught expected security error");
-        }
-
-        // The pool should process the async error
-        assertTrue("Should get new connection", Wait.waitFor(new 
Wait.Condition() {
-
-            @Override
-            public boolean isSatisified() throws Exception {
-                try (final PooledConnection newConnection = (PooledConnection) 
pooledConnFact.createConnection("invalid", "credentials")) {
-                    return connection1.getConnection() != 
newConnection.getConnection();
+        try (final Connection connection1 = 
pooledConnFact.createConnection("invalid", "credentials")) {
+            assertThrows(JMSSecurityException.class, connection1::start);
+
+            // The pool should process the async error
+            // we should eventually get a different connection instance from 
the pool regardless of the underlying connection
+            assertTrue("Should get new connection", Wait.waitFor(new 
Wait.Condition() {
+                @Override
+                public boolean isSatisified() throws Exception {
+                    try (final PooledConnection newConnection = 
(PooledConnection) pooledConnFact.createConnection("invalid", "credentials")) {
+                        return connection1 != newConnection;
+                    } catch (Exception e) {
+                        return false;
+                    }
                 }
+            }));
+
+            try (final PooledConnection connection2 = (PooledConnection) 
pooledConnFact.createConnection("invalid", "credentials")) {
+                assertNotSame(connection1, connection2);
             }
-        }));
-
-        final PooledConnection connection2 = (PooledConnection) 
pooledConnFact.createConnection("invalid", "credentials");
-        assertNotSame(connection1.getConnection(), 
connection2.getConnection());
-
-        try {
-            connection2.start();
-            fail("Should fail to connect");
-        } catch (JMSSecurityException ex) {
-            LOG.info("Caught expected security error");
-        } finally {
-            connection2.close();
-        }
 
-        connection1.close();
+            assertNull(((PooledConnection)connection1).getConnection()); // 
underlying connection should have been closed
+        }
     }
 
-    @Test
     public void testFailureGetsNewConnectionOnRetryBigPool() throws 
JMSException {
         pooledConnFact.setMaxConnections(10);
 
-        Connection connection1 = pooledConnFact.createConnection("invalid", 
"credentials");
-        try {
-            connection1.start();
-            fail("Should fail to connect");
-        } catch (JMSSecurityException ex) {
-            LOG.info("Caught expected security error");
-        }
-
-        Connection connection2 = pooledConnFact.createConnection("invalid", 
"credentials");
-        try {
-            connection2.start();
-            fail("Should fail to connect");
-        } catch (JMSSecurityException ex) {
-            LOG.info("Caught expected security error");
+        try (final Connection connection1 = 
pooledConnFact.createConnection("invalid", "credentials")) {
+            assertThrows(JMSSecurityException.class, connection1::start);
+            try (final Connection connection2 = 
pooledConnFact.createConnection("invalid", "credentials")) {
+                assertThrows(JMSSecurityException.class, connection2::start);
+                assertNotSame(connection1, connection2);
+            }
         }
 
-        assertNotSame(connection1, connection2);
-
-        connection1.close();
-        connection2.close();
     }
 
     @Test
@@ -190,21 +164,14 @@ public class PooledConnectionSecurityExceptionTest {
         pooledConnFact.setConnectionFactory(cf);
         pooledConnFact.setMaxConnections(1);
 
-        Connection connection = pooledConnFact.createConnection("invalid", 
"credentials");
+        try (final Connection connection = 
pooledConnFact.createConnection("invalid", "credentials")) {
+            assertThrows(JMSSecurityException.class, connection::start);
 
-        try {
-            connection.start();
-            fail("Should fail to connect");
-        } catch (JMSSecurityException ex) {
-            LOG.info("Caught expected security error");
+            try (final Connection connection2 = 
pooledConnFact.createConnection("system", "manager")) {
+                connection2.start();
+                LOG.info("Successfully create new connection.");
+            }
         }
-
-        connection = pooledConnFact.createConnection("system", "manager");
-        connection.start();
-
-        LOG.info("Successfully create new connection.");
-
-        connection.close();
     }
 
     @Test
@@ -217,64 +184,46 @@ public class PooledConnectionSecurityExceptionTest {
         pooledConnFact.setConnectionFactory(cf);
         pooledConnFact.setMaxConnections(1);
 
-        final PooledConnection connection1 = (PooledConnection) 
pooledConnFact.createConnection("invalid", "credentials");
+        try (final PooledConnection connection1 = (PooledConnection) 
pooledConnFact.createConnection("invalid", "credentials")) {
+            assertThrows(JMSSecurityException.class, connection1::start);
 
-        try {
-            connection1.start();
-            fail("Should fail to connect");
-        } catch (JMSSecurityException ex) {
-            LOG.info("Caught expected security error");
-            // Intentionally don't close here to see that async pool reconnect 
takes place.
-        }
+            // The pool should process the async error
+            assertTrue("Should get new connection", Wait.waitFor(new 
Wait.Condition() {
 
-        // The pool should process the async error
-        assertTrue("Should get new connection", Wait.waitFor(new 
Wait.Condition() {
-
-            @Override
-            public boolean isSatisified() throws Exception {
-                try (final PooledConnection newConnection = (PooledConnection) 
pooledConnFact.createConnection("invalid", "credentials")) {
-                    return connection1.getConnection() != 
newConnection.getConnection();
+                @Override
+                public boolean isSatisified() throws Exception {
+                    try (final PooledConnection newConnection = 
(PooledConnection) pooledConnFact.createConnection("invalid", "credentials")) {
+                        return connection1 != newConnection;
+                    } catch (Exception e) {
+                        return false;
+                    }
                 }
+            }));
+
+            try (final PooledConnection connection2 = (PooledConnection) 
pooledConnFact.createConnection("invalid", "credentials")) {
+                assertNotSame(connection1.pool, connection2.pool);
+                assertThrows(JMSSecurityException.class, connection2::start);
             }
-        }));
-
-        final PooledConnection connection2 = (PooledConnection) 
pooledConnFact.createConnection("invalid", "credentials");
-        assertNotSame(connection1.getConnection(), 
connection2.getConnection());
-
-        try {
-            connection2.start();
-            fail("Should fail to connect");
-        } catch (JMSSecurityException ex) {
-            LOG.info("Caught expected security error");
-            connection2.close();
-        } finally {
-            connection2.close();
         }
-
-        connection1.close();
     }
 
     @Test
     public void testFailedCreateConsumerConnectionStillWorks() throws 
JMSException {
-        Connection connection = pooledConnFact.createConnection("guest", 
"password");
-        connection.start();
+        try (final Connection connection = 
pooledConnFact.createConnection("guest", "password")) {
+            connection.start();
 
-        Session session = connection.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
-        Queue queue = session.createQueue(name.getMethodName());
+            try (final Session session = connection.createSession(false, 
Session.AUTO_ACKNOWLEDGE)) {
+                final Queue queue = session.createQueue(name.getMethodName());
 
-        try {
-            session.createConsumer(queue);
-            fail("Should fail to create consumer");
-        } catch (JMSSecurityException ex) {
-            LOG.info("Caught expected security error");
-        }
+                assertThrows(JMSSecurityException.class, () -> 
session.createConsumer(queue));
 
-        queue = session.createQueue("GUESTS." + name.getMethodName());
+                final Queue guestsQueue = session.createQueue("GUESTS." + 
name.getMethodName());
 
-        MessageProducer producer = session.createProducer(queue);
-        producer.close();
-
-        connection.close();
+                try (final MessageProducer producer = 
session.createProducer(guestsQueue)) {
+                    // We can still produce to the GUESTS queue.
+                }
+            }
+        }
     }
 
     public String getName() {
@@ -410,4 +359,4 @@ public class PooledConnectionSecurityExceptionTest {
 
         return authorizationPlugin;
     }
-}
+}
\ No newline at end of file
diff --git 
a/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/JournalCorruptionEofIndexRecoveryTest.java
 
b/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/JournalCorruptionEofIndexRecoveryTest.java
index a9b4c52258..c3b9fc2046 100644
--- 
a/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/JournalCorruptionEofIndexRecoveryTest.java
+++ 
b/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/JournalCorruptionEofIndexRecoveryTest.java
@@ -63,12 +63,12 @@ import org.apache.logging.log4j.core.filter.AbstractFilter;
 import org.apache.logging.log4j.core.layout.MessageLayout;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.event.LoggingEvent;
 
-
 public class JournalCorruptionEofIndexRecoveryTest {
 
     private static final Logger LOG = 
LoggerFactory.getLogger(JournalCorruptionEofIndexRecoveryTest.class);
diff --git 
a/activemq-unit-tests/src/test/java/org/apache/activemq/jms2/ActiveMQJMS2MessageListenerTest.java
 
b/activemq-unit-tests/src/test/java/org/apache/activemq/jms2/ActiveMQJMS2MessageListenerTest.java
index 873c45b207..2ca9209820 100644
--- 
a/activemq-unit-tests/src/test/java/org/apache/activemq/jms2/ActiveMQJMS2MessageListenerTest.java
+++ 
b/activemq-unit-tests/src/test/java/org/apache/activemq/jms2/ActiveMQJMS2MessageListenerTest.java
@@ -91,8 +91,8 @@ public class ActiveMQJMS2MessageListenerTest extends 
ActiveMQJMS2TestBase {
             jmsConsumer.setMessageListener(new MessageListener() {
                 @Override
                 public void onMessage(Message message) {
-                    countDownLatch.countDown();
                     receivedMessageCount.incrementAndGet();
+                    countDownLatch.countDown();
                     try {
                         switch(ackMode) {
                         case Session.CLIENT_ACKNOWLEDGE: 
message.acknowledge(); break;
diff --git 
a/activemq-unit-tests/src/test/java/org/apache/activemq/network/NetworkAdvancedStatisticsTest.java
 
b/activemq-unit-tests/src/test/java/org/apache/activemq/network/NetworkAdvancedStatisticsTest.java
index e18a66c3b0..c3cde8008e 100644
--- 
a/activemq-unit-tests/src/test/java/org/apache/activemq/network/NetworkAdvancedStatisticsTest.java
+++ 
b/activemq-unit-tests/src/test/java/org/apache/activemq/network/NetworkAdvancedStatisticsTest.java
@@ -110,7 +110,7 @@ public class NetworkAdvancedStatisticsTest extends 
BaseNetworkTest {
     }
 
     //Added for AMQ-9437 test advancedStatistics for networkEnqueue and 
networkDequeue
-    @Test(timeout = 60 * 1000)
+    @Test(timeout = 120 * 1000)
     public void testNetworkAdvancedStatistics() throws Exception {
 
         // create a remote durable consumer to create demand
@@ -159,7 +159,7 @@ public class NetworkAdvancedStatisticsTest extends 
BaseNetworkTest {
                 // The number of message that remain is due to the exclude 
queue
                 return receivedMessages.size() == MESSAGE_COUNT;
             }
-        }, 10000, 500));
+        }, 30000, 500));
 
         assertTrue(receivedExceptions.isEmpty());
         assertEquals(Integer.valueOf(MESSAGE_COUNT), 
Integer.valueOf(receivedMessages.size()));
@@ -236,7 +236,7 @@ public class NetworkAdvancedStatisticsTest extends 
BaseNetworkTest {
                 public boolean isSatisified() throws Exception {
                     return 
localBroker.getSystemUsage().getMemoryUsage().getUsage() == 0;
                 }
-            }, 10000, 500));
+            }, 30000, 500));
         } else {
             assertTrue(Wait.waitFor(new Condition() {
                 @Override
@@ -244,7 +244,7 @@ public class NetworkAdvancedStatisticsTest extends 
BaseNetworkTest {
                     // The number of message that remain is due to the exclude 
queue
                     return localBroker.getAdminView().getTotalMessageCount() 
== MESSAGE_COUNT;
                 }
-            }, 10000, 500));
+            }, 30000, 500));
         }
         remoteConsumer.close();
     }
@@ -265,4 +265,4 @@ public class NetworkAdvancedStatisticsTest extends 
BaseNetworkTest {
         }));
     }
 
-}
+}
\ No newline at end of file
diff --git 
a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/UsageBlockedDispatchTest.java
 
b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/UsageBlockedDispatchTest.java
index d371076675..59c8b3934c 100644
--- 
a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/UsageBlockedDispatchTest.java
+++ 
b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/UsageBlockedDispatchTest.java
@@ -26,6 +26,7 @@ import org.apache.activemq.broker.region.policy.PolicyMap;
 import org.apache.activemq.command.ActiveMQQueue;
 import org.apache.activemq.usage.SystemUsage;
 import org.apache.activemq.util.DefaultTestAppender;
+import org.apache.activemq.util.Wait;
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.core.LogEvent;
@@ -154,6 +155,8 @@ public class UsageBlockedDispatchTest extends TestSupport {
 
         try {
 
+            assertTrue("Timed out waiting for cursor to block", 
Wait.waitFor(() -> gotExpectedLogEvent.get()));
+
             MessageConsumer noDispatchConsumer = 
consumerSession.createConsumer(shouldBeStuckForDispatch);
 
             Message m = noDispatchConsumer.receive(messageReceiveTimeout);
diff --git a/pom.xml b/pom.xml
index e7b3ad99d3..819b2b0e8c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -969,13 +969,12 @@
             <redirectTestOutputToFile>true</redirectTestOutputToFile>
             <forkCount>1</forkCount>
             <reuseForks>true</reuseForks>
-            <argLine>-enableassertions</argLine>
             <failIfNoTests>false</failIfNoTests>
             <systemPropertyVariables>
                 <java.awt.headless>true</java.awt.headless>
                 
<org.apache.activemq.kahaDB.files.skipMetadataUpdate>true</org.apache.activemq.kahaDB.files.skipMetadataUpdate>
             </systemPropertyVariables>
-            <argLine>-Xmx512m</argLine>
+            <argLine>-enableassertions</argLine>
           </configuration>
         </plugin>
         <plugin>


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to