jamesnetherton commented on a change in pull request #3555:
URL: https://github.com/apache/camel-quarkus/pull/3555#discussion_r808045495
##########
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:
Can you elaborate a bit more? It's not entirely clear to me why it
matters in this context.
All it's doing is trying to track which class reserved a specific port.
Arguably we don't need to do that. It just provides some nice logging output
and a way to clear out stale entries from the `RESERVED_PORTS` map.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]