diff --git a/apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/service/config/ConfigServiceWithChangeCache.java b/apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/service/config/ConfigServiceWithChangeCache.java index f1862e6982a..961b08f3b59 100644 --- a/apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/service/config/ConfigServiceWithChangeCache.java +++ b/apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/service/config/ConfigServiceWithChangeCache.java @@ -54,7 +54,7 @@ public class ConfigServiceWithChangeCache extends ConfigServiceWithCache { private static final Logger logger = LoggerFactory.getLogger(ConfigServiceWithChangeCache.class); - private static final long DEFAULT_EXPIRED_AFTER_ACCESS_IN_SencondS = 10; + private static final long DEFAULT_EXPIRED_AFTER_ACCESS_IN_SENCONDS = 10; private static final String TRACER_EVENT_CHANGE_CACHE_LOAD_KEY = "ConfigChangeCache.LoadFromDBbyKey"; @@ -83,7 +83,7 @@ public void initialize() { private void buildReleaseCache() { CacheBuilder releasesCacheBuilder = CacheBuilder.newBuilder() - .expireAfterAccess(DEFAULT_EXPIRED_AFTER_ACCESS_IN_SencondS, TimeUnit.SECONDS); + .expireAfterAccess(DEFAULT_EXPIRED_AFTER_ACCESS_IN_SENCONDS, TimeUnit.SECONDS); releasesCache = releasesCacheBuilder.build(new CacheLoader>() { @Override @@ -113,21 +113,24 @@ public void handleMessage(ReleaseMessage message, String channel) { message.getMessage())) { return; } - + String messageKey = message.getMessage(); + if (bizConfig.isConfigServiceCacheKeyIgnoreCase()) { + messageKey = messageKey.toLowerCase(); + } + Transaction transaction = Tracer.newTransaction(TRACER_EVENT_CHANGE_CACHE_LOAD, messageKey); try { - String messageKey = message.getMessage(); - if (bizConfig.isConfigServiceCacheKeyIgnoreCase()) { - messageKey = messageKey.toLowerCase(); - } - Tracer.newTransaction(TRACER_EVENT_CHANGE_CACHE_LOAD, messageKey); - List namespaceInfo = ReleaseMessageKeyGenerator.messageToList(messageKey); Release latestRelease = releaseService.findLatestActiveRelease(namespaceInfo.get(0), namespaceInfo.get(1), namespaceInfo.get(2)); releasesCache.put(latestRelease.getReleaseKey(), Optional.ofNullable(latestRelease)); + + transaction.setStatus(Transaction.SUCCESS); } catch (Throwable ex) { + transaction.setStatus(ex); //ignore + } finally { + transaction.complete(); } }