diff --git a/starters/threadpool/server/src/main/java/cn/hippo4j/springboot/starter/core/CacheData.java b/starters/threadpool/server/src/main/java/cn/hippo4j/springboot/starter/core/CacheData.java index b935d843..70682159 100644 --- a/starters/threadpool/server/src/main/java/cn/hippo4j/springboot/starter/core/CacheData.java +++ b/starters/threadpool/server/src/main/java/cn/hippo4j/springboot/starter/core/CacheData.java @@ -18,8 +18,10 @@ package cn.hippo4j.springboot.starter.core; import cn.hippo4j.common.executor.ThreadPoolExecutorRegistry; +import cn.hippo4j.common.model.ThreadPoolParameterInfo; import cn.hippo4j.springboot.starter.wrapper.ManagerListenerWrapper; import cn.hippo4j.common.toolkit.ContentUtil; +import cn.hippo4j.common.toolkit.JSONUtil; import cn.hippo4j.common.toolkit.Md5Util; import cn.hippo4j.common.toolkit.IncrementalContentUtil; import cn.hippo4j.common.constant.Constants; @@ -58,10 +60,12 @@ public class CacheData { this.tenantId = tenantId; this.itemId = itemId; this.threadPoolId = threadPoolId; - this.content = IncrementalContentUtil.getIncrementalContent( - ThreadPoolExecutorRegistry.getHolder(threadPoolId).getParameterInfo(), - IncrementalContentUtil.PROTOCOL_VERSION); - this.md5 = getMd5String(content); + // Store full content for listeners to receive complete configuration + ThreadPoolParameterInfo parameterInfo = ThreadPoolExecutorRegistry.getHolder(threadPoolId).getParameterInfo(); + this.content = ContentUtil.getPoolContent(parameterInfo); + // Calculate MD5 based on incremental content for version compatibility + String incrementalContent = IncrementalContentUtil.getIncrementalContent(parameterInfo, IncrementalContentUtil.PROTOCOL_VERSION); + this.md5 = getMd5String(incrementalContent); this.listeners = new CopyOnWriteArrayList<>(); } @@ -97,8 +101,17 @@ public class CacheData { } public void setContent(String content) { + // Store full content for listeners this.content = content; - this.md5 = getMd5String(this.content); + // Calculate MD5 based on incremental content for version compatibility + try { + ThreadPoolParameterInfo parameterInfo = JSONUtil.parseObject(content, ThreadPoolParameterInfo.class); + String incrementalContent = IncrementalContentUtil.getIncrementalContent(parameterInfo, IncrementalContentUtil.PROTOCOL_VERSION); + this.md5 = getMd5String(incrementalContent); + } catch (Exception e) { + // Fallback to full content MD5 if parsing fails + this.md5 = getMd5String(content); + } } public static String getMd5String(String config) { diff --git a/starters/threadpool/server/src/main/java/cn/hippo4j/springboot/starter/core/ClientWorker.java b/starters/threadpool/server/src/main/java/cn/hippo4j/springboot/starter/core/ClientWorker.java index e454394c..9ee5c95d 100644 --- a/starters/threadpool/server/src/main/java/cn/hippo4j/springboot/starter/core/ClientWorker.java +++ b/starters/threadpool/server/src/main/java/cn/hippo4j/springboot/starter/core/ClientWorker.java @@ -157,9 +157,7 @@ public class ClientWorker implements DisposableBean { try { String content = getServerConfig(namespace, itemId, tpId, defaultTimedOut); CacheData cacheData = cacheMap.get(tpId); - ThreadPoolParameterInfo poolInfo = JSONUtil.parseObject(content, ThreadPoolParameterInfo.class); - // Use incremental content for protocol version 2+ clients - String poolContent = IncrementalContentUtil.getIncrementalContent(poolInfo, IncrementalContentUtil.PROTOCOL_VERSION); + String poolContent = ContentUtil.getPoolContent(JSONUtil.parseObject(content, ThreadPoolParameterInfo.class)); cacheData.setContent(poolContent); } catch (Exception ignored) { log.error("Failed to get the latest thread pool configuration.", ignored); @@ -288,9 +286,7 @@ public class ClientWorker implements DisposableBean { try { serverConfig = getServerConfig(namespace, itemId, threadPoolId, defaultTimedOut); ThreadPoolParameterInfo poolInfo = JSONUtil.parseObject(serverConfig, ThreadPoolParameterInfo.class); - // Use incremental content for protocol version 2+ clients - String content = IncrementalContentUtil.getIncrementalContent(poolInfo, IncrementalContentUtil.PROTOCOL_VERSION); - cacheData.setContent(content); + cacheData.setContent(ContentUtil.getPoolContent(poolInfo)); } catch (Exception ex) { log.error("Cache Data Error. Service Unavailable: {}", ex.getMessage()); }