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/karaf.git


The following commit(s) were added to refs/heads/main by this push:
     new c042b103a1 fix(audit): bind the UDP socket of EventLoggerTest on an 
ephemeral port (#3103)
c042b103a1 is described below

commit c042b103a1c2c119d259a6bb47b4d1cb47d92fa6
Author: JB Onofré <[email protected]>
AuthorDate: Mon Nov 16 13:04:08 2026 +0000

    fix(audit): bind the UDP socket of EventLoggerTest on an ephemeral port 
(#3103)
    
    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.
---
 .../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