Quellcode durchsuchen

Fix possiable NPE (#3832)

* Fix possiable NPE

* Update CHANGES.md
Lonre Wang vor 3 Jahren
Ursprung
Commit
b2d666f68e

+ 1 - 0
CHANGES.md

@@ -57,6 +57,7 @@ Apollo 1.9.0
 * [speed up the stale issue mark and close phase](https://github.com/ctripcorp/apollo/pull/3808)
 * [feature: add the delegating password encoder for apollo-portal simple auth](https://github.com/ctripcorp/apollo/pull/3804)
 * [support release apollo-client-config-data](https://github.com/ctripcorp/apollo/pull/3822)
+* [Fix possiable NPE](https://github.com/ctripcorp/apollo/pull/3832)
 * [Reduce bootstrap time in the situation with large properties](https://github.com/ctripcorp/apollo/pull/3816)
 * [docs: English catalog in sidebar](https://github.com/ctripcorp/apollo/pull/3831)
 * [fix the issue that release messages might be missed in certain scenarios](https://github.com/ctripcorp/apollo/pull/3819)

+ 3 - 3
apollo-core/src/main/java/com/ctrip/framework/apollo/core/utils/DeferredLogCache.java

@@ -21,7 +21,6 @@ import com.google.common.cache.CacheBuilder;
 import org.slf4j.Logger;
 import org.slf4j.event.Level;
 
-import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
 /**
@@ -36,7 +35,6 @@ final class DeferredLogCache {
   private static final AtomicInteger LOG_INDEX = new AtomicInteger(0);
   private static final Cache<Integer, Line> LOG_CACHE = CacheBuilder.newBuilder()
       .maximumSize(MAX_LOG_SIZE)
-      .expireAfterWrite(1, TimeUnit.MINUTES)
       .build();
 
   private DeferredLogCache() {
@@ -85,7 +83,9 @@ final class DeferredLogCache {
   static void replayTo() {
     for (int i = 1; i <= LOG_INDEX.get(); i++) {
       Line logLine = LOG_CACHE.getIfPresent(i);
-      assert logLine != null;
+      if (logLine == null) {
+        continue;
+      }
       Logger logger = logLine.getLogger();
       Level level = logLine.getLevel();
       String message = logLine.getMessage();