ppalaga commented on a change in pull request #3555:
URL: https://github.com/apache/camel-quarkus/pull/3555#discussion_r808019076



##########
File path: 
integration-tests-support/test-support/src/main/java/org/apache/camel/quarkus/test/AvailablePortFinder.java
##########
@@ -54,15 +57,23 @@ private AvailablePortFinder() {
      * @return                       the available port
      */
     public static int getNextAvailable() {
+        // Using AvailablePortFinder in native applications can be problematic
+        // E.g The reserved port may be allocated at build time and preserved 
indefinitely at runtime. I.e it never changes on each execution of the native 
application
+        logWarningIfNativeApplication();
+
         while (true) {
             try (ServerSocket ss = new ServerSocket()) {
                 ss.setReuseAddress(true);
                 ss.bind(new InetSocketAddress((InetAddress) null, 0), 1);
 
                 int port = ss.getLocalPort();
                 if (!isQuarkusReservedPort(port)) {
-                    LOGGER.info("getNextAvailable() -> {}", port);
-                    return port;
+                    String callerClassName = getCallerClassName();
+                    String value = RESERVED_PORTS.putIfAbsent(port, 
callerClassName);

Review comment:
       Is this making some assumptions about whether this class can 
concurrently exist in multiple JVMs or multiple class loaders within a single 
maven invocation? IIRC surefire is forking a new JVM for each Maven module. So 
if building with mvnd, the AvailablePortFinder class may exist in several 
concurrent JVMs. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to