From c38a19c6c6eebfed17da55059f61799b8613b272 Mon Sep 17 00:00:00 2001 From: xzyJavaX <49760141+xzyJavaX@users.noreply.github.com> Date: Sat, 29 Jul 2023 03:29:17 +0800 Subject: [PATCH] fix the conditions for resetting uuid in dynamic configuration (#588) --- CHANGES.md | 1 + .../core/conf/dynamic/ConfigurationDiscoveryService.java | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 06e524ef2..039e7c2d4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -149,6 +149,7 @@ Callable { * Upgrade guava to 32.0.1 * Fix issue with duplicate enhancement by ThreadPoolExecutor * Add plugin to support for RESTeasy 6.x. +* Fix the conditions for resetting uuid, avoid the same uuid causing the configuration not to be updated. #### Documentation diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/dynamic/ConfigurationDiscoveryService.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/dynamic/ConfigurationDiscoveryService.java index 9e53452bc..661adc60c 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/dynamic/ConfigurationDiscoveryService.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/dynamic/ConfigurationDiscoveryService.java @@ -219,7 +219,7 @@ public class ConfigurationDiscoveryService implements BootService, GRPCChannelLi builder.setService(Config.Agent.SERVICE_NAME); // Some plugin will register watcher later. - final int size = register.keys().size(); + final int size = register.getRegisterWatcherSize(); if (lastRegisterWatcherSize != size) { // reset uuid, avoid the same uuid causing the configuration not to be updated. uuid = null; @@ -273,6 +273,12 @@ public class ConfigurationDiscoveryService implements BootService, GRPCChannelLi return register.keySet(); } + public int getRegisterWatcherSize() { + return register.values().stream() + .mapToInt(List::size) + .sum(); + } + @Override public String toString() { ArrayList registerTableDescription = new ArrayList<>(register.size());