Skip to content

Commit 195b930

Browse files
fix: add RdsHostListProvider.getClusterId() to call init() in case of… (#1162)
1 parent faf104b commit 195b930

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

wrapper/src/main/java/software/amazon/jdbc/HostListProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ public interface HostListProvider {
4242

4343
HostSpec identifyConnection(Connection connection) throws SQLException;
4444

45-
String getClusterId() throws UnsupportedOperationException;
45+
String getClusterId() throws UnsupportedOperationException, SQLException;
4646
}

wrapper/src/main/java/software/amazon/jdbc/hostlistprovider/RdsHostListProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,8 @@ public HostSpec identifyConnection(Connection connection) throws SQLException {
694694
}
695695

696696
@Override
697-
public String getClusterId() throws UnsupportedOperationException {
697+
public String getClusterId() throws UnsupportedOperationException, SQLException {
698+
init();
698699
return this.clusterId;
699700
}
700701

wrapper/src/main/java/software/amazon/jdbc/plugin/limitless/LimitlessRouterServiceImpl.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,18 @@
2424
import java.util.concurrent.ConcurrentHashMap;
2525
import java.util.concurrent.TimeUnit;
2626
import java.util.concurrent.locks.ReentrantLock;
27+
import java.util.logging.Logger;
2728
import org.checkerframework.checker.nullness.qual.NonNull;
2829
import software.amazon.jdbc.AwsWrapperProperty;
2930
import software.amazon.jdbc.HostSpec;
3031
import software.amazon.jdbc.PluginService;
32+
import software.amazon.jdbc.util.Messages;
3133
import software.amazon.jdbc.util.SlidingExpirationCacheWithCleanupThread;
3234
import software.amazon.jdbc.util.Utils;
3335

3436
public class LimitlessRouterServiceImpl implements LimitlessRouterService {
37+
private static final Logger LOGGER =
38+
Logger.getLogger(LimitlessRouterServiceImpl.class.getName());
3539
public static final AwsWrapperProperty MONITOR_DISPOSAL_TIME_MS =
3640
new AwsWrapperProperty(
3741
"limitlessTransactionRouterMonitorDisposalTimeMs",
@@ -143,12 +147,13 @@ public void startMonitoring(final @NonNull HostSpec hostSpec,
143147
.createLimitlessRouterMonitor(
144148
hostSpec,
145149
limitlessRouterCache,
146-
this.pluginService.getHostListProvider().getClusterId(),
150+
limitlessRouterMonitorKey,
147151
props,
148152
intervalMs),
149153
cacheExpirationNano);
150-
} catch (UnsupportedOperationException e) {
151-
throw e;
154+
} catch (SQLException e) {
155+
LOGGER.warning(Messages.get("LimitlessRouterServiceImpl.errorStartingMonitor", new Object[]{e}));
156+
throw new RuntimeException(e);
152157
}
153158
}
154159
}

wrapper/src/main/resources/aws_advanced_jdbc_wrapper_messages.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ LimitlessRouterMonitor.openedConnection=Opened Limitless Router Monitor connecti
243243
LimitlessRouterMonitor.running=Limitless Router Monitor thread running on node {0}.
244244
LimitlessRouterMonitor.stopped=Limitless Router Monitor thread stopped on node {0].
245245

246+
# Limitless Router Service
247+
LimitlessRouterServiceImpl.errorStartingMonitor=An error occurred while starting Limitless Router Monitor. {0}
248+
246249
# Log Query Connection Plugin
247250
LogQueryConnectionPlugin.executingQuery=[{0}] Executing query: {1}
248251

0 commit comments

Comments
 (0)