From 0fecc5fda56733b60a99b530895ceb62c516ac54 Mon Sep 17 00:00:00 2001 From: Rafael Bey <24432403+rafaelbey@users.noreply.github.com> Date: Wed, 13 Mar 2024 20:47:00 -0400 Subject: [PATCH] use port zero to allow OS to determine best free port to use (#2698) --- .../plan/execution/stores/relational/H2LocalServer.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-connection/src/main/java/org/finos/legend/engine/plan/execution/stores/relational/H2LocalServer.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-connection/src/main/java/org/finos/legend/engine/plan/execution/stores/relational/H2LocalServer.java index f3ad63d4fde..808e6500ff9 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-connection/src/main/java/org/finos/legend/engine/plan/execution/stores/relational/H2LocalServer.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-connection/src/main/java/org/finos/legend/engine/plan/execution/stores/relational/H2LocalServer.java @@ -20,18 +20,17 @@ public class H2LocalServer { - private static final H2LocalServer INSTANCE = new H2LocalServer(DynamicPortGenerator.generatePort()); + private static final H2LocalServer INSTANCE = new H2LocalServer(); private final int port; - private H2LocalServer(int port) + private H2LocalServer() { - this.port = port; try { // We can create only one instance of the server as the databases are anyway shared in the process (VM) // The important part is to have an empty name in 'this.buildDataSource("127.0.0.1", localH2Port, "", null)' // It ensure the database creation is 'private' to the connection. - AlloyH2Server.startServer(port); + this.port = AlloyH2Server.startServer(0).getPort(); } catch (SQLException e) {