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

jbonofre pushed a commit to branch karaf-4.4.x
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/karaf-4.4.x by this push:
     new f527275c0a fix(audit): bind the UDP socket of EventLoggerTest on an 
ephemeral port (#3104)
f527275c0a is described below

commit f527275c0a4704d5cb775ece17af40cd3cff23ca
Author: JB Onofré <[email protected]>
AuthorDate: Mon Nov 16 15:32:47 2026 +0000

    fix(audit): bind the UDP socket of EventLoggerTest on an ephemeral port 
(#3104)
    
    testUdp took a port free for TCP, from a ServerSocket, and bound a
    DatagramSocket on it. A port free for TCP may be in use for UDP, so the
    test failed now and then with "Address already in use". The socket is now
    bound on an ephemeral UDP port.
    
    (cherry picked from commit bef4512c4c49584080b2d74c5678b9a2b8dc78ed)
---
 .../test/java/org/apache/karaf/audit/logger/EventLoggerTest.java    | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/audit/src/test/java/org/apache/karaf/audit/logger/EventLoggerTest.java 
b/audit/src/test/java/org/apache/karaf/audit/logger/EventLoggerTest.java
index f9f7a81994..caa0436a53 100644
--- a/audit/src/test/java/org/apache/karaf/audit/logger/EventLoggerTest.java
+++ b/audit/src/test/java/org/apache/karaf/audit/logger/EventLoggerTest.java
@@ -67,9 +67,9 @@ public class EventLoggerTest {
         map.put("params", new Object[] { new 
ObjectName("org.apache.karaf.Mbean:type=foo"), "myMethod", new Object[] { 
String.class.getName() }, new String[] { "the-param "}});
         Event event = new MapEvent(map, 1510902000000L);
 
-        int port = getNewPort();
-
-        DatagramSocket socket = new DatagramSocket(port);
+        // an ephemeral UDP port: a port free for TCP may be in use for UDP
+        DatagramSocket socket = new DatagramSocket();
+        int port = socket.getLocalPort();
         List<DatagramPacket> packets = new ArrayList<>();
         new Thread(() -> {
             try {

Reply via email to