You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gn...@apache.org on 2026/03/20 12:23:30 UTC

(camel) branch CAMEL-23214-port-misc created (now 4b148a9ff105)

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

gnodet pushed a change to branch CAMEL-23214-port-misc
in repository https://gitbox.apache.org/repos/asf/camel.git


      at 4b148a9ff105 CAMEL-23214: Fix flaky JMXRobustRemoteConnectionTest - use @RegisterExtension for port and cleanup RMI registry

This branch includes the following new commits:

     new 4b148a9ff105 CAMEL-23214: Fix flaky JMXRobustRemoteConnectionTest - use @RegisterExtension for port and cleanup RMI registry

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(camel) 01/01: CAMEL-23214: Fix flaky JMXRobustRemoteConnectionTest - use @RegisterExtension for port and cleanup RMI registry

Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch CAMEL-23214-port-misc
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 4b148a9ff1057ab3233a100e981bfd7fde3646cf
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Fri Mar 20 13:23:14 2026 +0100

    CAMEL-23214: Fix flaky JMXRobustRemoteConnectionTest - use @RegisterExtension for port and cleanup RMI registry
    
    Co-Authored-By: Claude Opus 4.6 <no...@anthropic.com>
---
 .../component/jmx/JMXRobustRemoteConnectionTest.java | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXRobustRemoteConnectionTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXRobustRemoteConnectionTest.java
index 7d20972c0457..35c0bedadcfa 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXRobustRemoteConnectionTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXRobustRemoteConnectionTest.java
@@ -17,8 +17,10 @@
 package org.apache.camel.component.jmx;
 
 import java.io.File;
+import java.rmi.NoSuchObjectException;
 import java.rmi.registry.LocateRegistry;
 import java.rmi.registry.Registry;
+import java.rmi.server.UnicastRemoteObject;
 import java.util.Collections;
 
 import javax.management.MBeanServerFactory;
@@ -26,9 +28,11 @@ import javax.management.remote.JMXConnectorServer;
 import javax.management.remote.JMXConnectorServerFactory;
 import javax.management.remote.JMXServiceURL;
 
+import org.apache.camel.test.AvailablePortFinder;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -45,6 +49,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
  */
 public class JMXRobustRemoteConnectionTest extends SimpleBeanFixture {
 
+    @RegisterExtension
+    AvailablePortFinder.Port portHolder = AvailablePortFinder.find();
+
     JMXServiceURL url;
     JMXConnectorServer connector;
     Registry registry;
@@ -53,6 +60,7 @@ public class JMXRobustRemoteConnectionTest extends SimpleBeanFixture {
     @BeforeEach
     @Override
     public void setUp() throws Exception {
+        port = portHolder.getPort();
         url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + port + "/" + DOMAIN);
 
         initContext();
@@ -63,7 +71,17 @@ public class JMXRobustRemoteConnectionTest extends SimpleBeanFixture {
     @AfterEach
     public void tearDown() throws Exception {
         super.tearDown();
-        connector.stop();
+        if (connector != null) {
+            connector.stop();
+        }
+        if (registry != null) {
+            try {
+                UnicastRemoteObject.unexportObject(registry, true);
+            } catch (NoSuchObjectException e) {
+                // Already unexported, ignore
+            }
+            registry = null;
+        }
     }
 
     @Override