From 2e2919d21c4590212b6b471075f81749e4606c26 Mon Sep 17 00:00:00 2001 From: Lonre Wang Date: Tue, 10 Aug 2021 21:47:47 +0800 Subject: [PATCH] Polish log --- CHANGES.md | 1 + .../apollo/spring/property/SpringValueRegistry.java | 8 ++++++-- .../ctrip/framework/apollo/mockserver/EmbeddedApollo.java | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index e5265f55301..5b3c4c5971f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -74,6 +74,7 @@ Apollo 1.9.0 * [Fix Multiple PropertySourcesPlaceholderConfigurer beans registered issue](https://github.com/ctripcorp/apollo/pull/3865) * [use jdk 8 to publish apollo-client-config-data](https://github.com/ctripcorp/apollo/pull/3880) * [fix apollo config data loader with profiles](https://github.com/ctripcorp/apollo/pull/3870) +* [polish log](https://github.com/ctripcorp/apollo/pull/3882) ------------------ All issues and pull requests are [here](https://github.com/ctripcorp/apollo/milestone/6?closed=1) diff --git a/apollo-client/src/main/java/com/ctrip/framework/apollo/spring/property/SpringValueRegistry.java b/apollo-client/src/main/java/com/ctrip/framework/apollo/spring/property/SpringValueRegistry.java index c3e120c80ec..e5fdb1a4d19 100644 --- a/apollo-client/src/main/java/com/ctrip/framework/apollo/spring/property/SpringValueRegistry.java +++ b/apollo-client/src/main/java/com/ctrip/framework/apollo/spring/property/SpringValueRegistry.java @@ -20,6 +20,7 @@ import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.Maps; import com.google.common.collect.Multimap; +import com.google.common.collect.Multimaps; import java.util.Collection; import java.util.Iterator; import java.util.Map; @@ -28,10 +29,13 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import com.google.common.collect.Multimaps; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.BeanFactory; public class SpringValueRegistry { + private static final Logger logger = LoggerFactory.getLogger(SpringValueRegistry.class); + private static final long CLEAN_INTERVAL_IN_SECONDS = 5; private final Map> registry = Maps.newConcurrentMap(); private final AtomicBoolean initialized = new AtomicBoolean(false); @@ -70,7 +74,7 @@ public void run() { try { scanAndClean(); } catch (Throwable ex) { - ex.printStackTrace(); + logger.error(ex.getMessage(), ex); } } }, CLEAN_INTERVAL_IN_SECONDS, CLEAN_INTERVAL_IN_SECONDS, TimeUnit.SECONDS); diff --git a/apollo-mockserver/src/main/java/com/ctrip/framework/apollo/mockserver/EmbeddedApollo.java b/apollo-mockserver/src/main/java/com/ctrip/framework/apollo/mockserver/EmbeddedApollo.java index 5f111fd5d1e..7f6883412d4 100644 --- a/apollo-mockserver/src/main/java/com/ctrip/framework/apollo/mockserver/EmbeddedApollo.java +++ b/apollo-mockserver/src/main/java/com/ctrip/framework/apollo/mockserver/EmbeddedApollo.java @@ -66,7 +66,7 @@ public class EmbeddedApollo extends ExternalResource { CONFIG_SERVICE_LOCATOR_CLEAR = ConfigServiceLocator.class.getDeclaredMethod("initConfigServices"); CONFIG_SERVICE_LOCATOR_CLEAR.setAccessible(true); } catch (NoSuchMethodException e) { - e.printStackTrace(); + logger.error(e.getMessage(), e); } }