From bd7beb4de48a7704ce5a5ac97b98a0aeb0ef0d77 Mon Sep 17 00:00:00 2001 From: Aaron Chung Date: Fri, 13 Dec 2024 14:41:29 -0800 Subject: [PATCH] fix: Limitless plugin set round robin weights to original props used by the round robin host selector, not a copy --- .../amazon/jdbc/plugin/limitless/LimitlessRouterMonitor.java | 4 +++- .../jdbc/plugin/limitless/LimitlessRouterServiceImpl.java | 4 +++- .../jdbc/plugin/limitless/LimitlessRouterServiceImplTest.java | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/wrapper/src/main/java/software/amazon/jdbc/plugin/limitless/LimitlessRouterMonitor.java b/wrapper/src/main/java/software/amazon/jdbc/plugin/limitless/LimitlessRouterMonitor.java index 038c189ac..a48206c07 100644 --- a/wrapper/src/main/java/software/amazon/jdbc/plugin/limitless/LimitlessRouterMonitor.java +++ b/wrapper/src/main/java/software/amazon/jdbc/plugin/limitless/LimitlessRouterMonitor.java @@ -137,7 +137,9 @@ public void run() { newLimitlessRouters, TimeUnit.MILLISECONDS.toNanos(LimitlessRouterServiceImpl.MONITOR_DISPOSAL_TIME_MS.getLong(props))); - RoundRobinHostSelector.setRoundRobinHostWeightPairsProperty(this.props, newLimitlessRouters); + RoundRobinHostSelector.setRoundRobinHostWeightPairsProperty( + this.pluginService.getProperties(), + newLimitlessRouters); LOGGER.finest(Utils.logTopology(newLimitlessRouters, "[limitlessRouterMonitor] Topology:")); TimeUnit.MILLISECONDS.sleep(this.intervalMs); // do not include this in the telemetry } catch (final InterruptedException exception) { diff --git a/wrapper/src/main/java/software/amazon/jdbc/plugin/limitless/LimitlessRouterServiceImpl.java b/wrapper/src/main/java/software/amazon/jdbc/plugin/limitless/LimitlessRouterServiceImpl.java index 3404a9b56..6c09f3bd7 100644 --- a/wrapper/src/main/java/software/amazon/jdbc/plugin/limitless/LimitlessRouterServiceImpl.java +++ b/wrapper/src/main/java/software/amazon/jdbc/plugin/limitless/LimitlessRouterServiceImpl.java @@ -131,7 +131,9 @@ public void establishConnection(final LimitlessConnectionContext context) throws return; } - RoundRobinHostSelector.setRoundRobinHostWeightPairsProperty(context.getProps(), context.getLimitlessRouters()); + RoundRobinHostSelector.setRoundRobinHostWeightPairsProperty( + this.pluginService.getProperties(), + context.getLimitlessRouters()); HostSpec selectedHostSpec; try { selectedHostSpec = this.pluginService.getHostSpecByStrategy( diff --git a/wrapper/src/test/java/software/amazon/jdbc/plugin/limitless/LimitlessRouterServiceImplTest.java b/wrapper/src/test/java/software/amazon/jdbc/plugin/limitless/LimitlessRouterServiceImplTest.java index a2f85cea8..7a558551b 100644 --- a/wrapper/src/test/java/software/amazon/jdbc/plugin/limitless/LimitlessRouterServiceImplTest.java +++ b/wrapper/src/test/java/software/amazon/jdbc/plugin/limitless/LimitlessRouterServiceImplTest.java @@ -70,6 +70,7 @@ public void init() throws SQLException { props = new Properties(); when(mockConnectFuncLambda.call()).thenReturn(mockConnection); when(mockPluginService.getHostListProvider()).thenReturn(mockHostListProvider); + when(mockPluginService.getProperties()).thenReturn(props); when(mockHostListProvider.getClusterId()).thenReturn(CLUSTER_ID); }