From e58a5ed31daa2aee5fd099e6228cd55cc20af0d4 Mon Sep 17 00:00:00 2001 From: Robert Manning Date: Tue, 13 Feb 2024 16:00:34 -0500 Subject: [PATCH 1/2] fix: move config validation to startup stage so bad configs will break the component --- .../greengrass/clientdevices/auth/ClientDevicesAuthService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/aws/greengrass/clientdevices/auth/ClientDevicesAuthService.java b/src/main/java/com/aws/greengrass/clientdevices/auth/ClientDevicesAuthService.java index 275923517..6b01f02ac 100644 --- a/src/main/java/com/aws/greengrass/clientdevices/auth/ClientDevicesAuthService.java +++ b/src/main/java/com/aws/greengrass/clientdevices/auth/ClientDevicesAuthService.java @@ -108,7 +108,6 @@ protected void install() throws InterruptedException { context.get(CertificateManager.class).updateCertificatesConfiguration(new CertificatesConfig(getConfig())); initializeInfrastructure(); initializeHandlers(); - subscribeToConfigChanges(); } private int getValidCloudCallQueueSize(Topics topics) { @@ -214,6 +213,7 @@ private void configChangeHandler(WhatHappened whatHappened, Node node) { @Override protected void startup() throws InterruptedException { context.get(CertificateManager.class).startMonitors(); + subscribeToConfigChanges(); super.startup(); } From 179c9010ae5a694830d6a41232abca8ec4ac3acf Mon Sep 17 00:00:00 2001 From: Robert Manning Date: Tue, 13 Feb 2024 17:04:30 -0500 Subject: [PATCH 2/2] fix: make config change callback a final field --- .../clientdevices/auth/ClientDevicesAuthService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/aws/greengrass/clientdevices/auth/ClientDevicesAuthService.java b/src/main/java/com/aws/greengrass/clientdevices/auth/ClientDevicesAuthService.java index 6b01f02ac..fb9e23edc 100644 --- a/src/main/java/com/aws/greengrass/clientdevices/auth/ClientDevicesAuthService.java +++ b/src/main/java/com/aws/greengrass/clientdevices/auth/ClientDevicesAuthService.java @@ -37,6 +37,7 @@ import com.aws.greengrass.clientdevices.auth.session.SessionCreator; import com.aws.greengrass.clientdevices.auth.session.SessionManager; import com.aws.greengrass.clientdevices.auth.util.ResizableLinkedBlockingQueue; +import com.aws.greengrass.config.ChildChanged; import com.aws.greengrass.config.Node; import com.aws.greengrass.config.Topics; import com.aws.greengrass.config.WhatHappened; @@ -83,6 +84,7 @@ public class ClientDevicesAuthService extends PluginService { private static final int DEFAULT_CLOUD_CALL_QUEUE_SIZE = 100; private static final int DEFAULT_THREAD_POOL_SIZE = 1; public static final int DEFAULT_MAX_ACTIVE_AUTH_TOKENS = 2500; + private final ChildChanged configChangeHandler = this::configChangeHandler; // Create a threadpool for calling the cloud. Single thread will be used by default. private ThreadPoolExecutor cloudCallThreadPool; @@ -162,7 +164,7 @@ private void initializeHandlers() { private void subscribeToConfigChanges() { onConfigurationChanged(); - config.lookupTopics(CONFIGURATION_CONFIG_KEY).subscribe(this::configChangeHandler); + config.lookupTopics(CONFIGURATION_CONFIG_KEY).subscribe(configChangeHandler); } private void onConfigurationChanged() {