This is an automated email from the ASF dual-hosted git repository. MartijnVisser pushed a commit to branch release-2.4 in repository https://gitbox.apache.org/repos/asf/flink.git
commit 30f7ee50e122b1b88f7d1e93cd7095b6b761c0d1 Author: Dale Lane <[email protected]> AuthorDate: Tue Oct 20 20:43:08 2026 +0100 [FLINK-41048][container] Avoid JMX port race condition In reviewing the MiniCluster port fix, I remembered that I'd used the same NetUtils.getAvailablePort approach to reserve a predictable port number for the JMX server in the startsJmxServerOnConfiguredPort test. I've used a simpler approach here, as I just need to make sure that the MiniCluster registers - I'm giving it a wide range of port numbers to choose from, and verifying that it registers with one of them. This should be safe even on the busiest CI worker. Signed-off-by: Dale Lane <[email protected]> (cherry picked from commit e38a54e4940ad0cc0d8a2ad6b08815bfb1f15de6) --- .../entrypoint/MiniClusterJobEntryPointITCase.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/flink-container/src/test/java/org/apache/flink/container/entrypoint/MiniClusterJobEntryPointITCase.java b/flink-container/src/test/java/org/apache/flink/container/entrypoint/MiniClusterJobEntryPointITCase.java index 7c2f98afa2f..9f9620fdfdb 100644 --- a/flink-container/src/test/java/org/apache/flink/container/entrypoint/MiniClusterJobEntryPointITCase.java +++ b/flink-container/src/test/java/org/apache/flink/container/entrypoint/MiniClusterJobEntryPointITCase.java @@ -73,7 +73,6 @@ import org.apache.flink.runtime.util.ZooKeeperUtils; import org.apache.flink.runtime.zookeeper.ZooKeeperExtension; import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; import org.apache.flink.streaming.api.functions.sink.v2.DiscardingSink; -import org.apache.flink.util.NetUtils; import org.apache.flink.util.jackson.JacksonMapperFactory; import org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework; @@ -817,10 +816,6 @@ class MiniClusterJobEntryPointITCase { @Test void startsJmxServerOnConfiguredPort() throws Exception { - final int jmxPort; - try (NetUtils.Port port = NetUtils.getAvailablePort()) { - jmxPort = port.getPort(); - } final Process process = startProcess( "process", @@ -829,9 +824,18 @@ class MiniClusterJobEntryPointITCase { RecordingJob.class, List.of( dynamicProperty( - JMXServerOptions.JMX_SERVER_PORT, jmxPort)))); + JMXServerOptions.JMX_SERVER_PORT, "21010-21110")))); try { - awaitClusterServing(process, "process"); + final int jmxPort = + awaitRest( + process, + "process", + "/taskmanagers", + "a TaskManager with a JMX server", + json -> json.at("/taskmanagers/0/jmxPort").asInt(-1) > 0) + .at("/taskmanagers/0/jmxPort") + .asInt(); + assertThat(jmxPort).isBetween(21010, 21110); final JMXServiceURL url = new JMXServiceURL( "service:jmx:rmi://localhost:"
