Commit a070d12bed2e38b680758e3541cf144300889c2e

Authored by ci-aliyun
1 parent 41e3ed79

#fix:修复不开启1级缓存时报NullException的bug

... ... @@ -6,7 +6,7 @@
6 6  
7 7 <groupId>com.irrigation</groupId>
8 8 <artifactId>common-lib</artifactId>
9   - <version>2.0.0</version>
  9 + <version>2.0.1</version>
10 10  
11 11 <properties>
12 12 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
... ...
src/main/java/com/irrigation/icl/cache/LayeringCacheAutoFactory.java
... ... @@ -55,8 +55,10 @@ public class LayeringCacheAutoFactory {
55 55 MessageListenerAdapter listenerAdapter) {
56 56 RedisMessageListenerContainer container = new RedisMessageListenerContainer();
57 57 container.setConnectionFactory(connectionFactory);
58   - container.addMessageListener(listenerAdapter, new PatternTopic(layeringCacheProperties.getCacheL1().getTopic()));
59   -
  58 + LayeringCacheProperties.L1 l1 = layeringCacheProperties.getCacheL1();
  59 + if (l1 != null) {
  60 + container.addMessageListener(listenerAdapter, new PatternTopic(layeringCacheProperties.getCacheL1().getTopic()));
  61 + }
60 62 return container;
61 63 }
62 64  
... ...
src/main/java/com/irrigation/icl/cache/core/LayeringCache.java
... ... @@ -20,6 +20,7 @@ import org.springframework.util.StopWatch;
20 20  
21 21 import java.text.SimpleDateFormat;
22 22 import java.util.Date;
  23 +import java.util.Optional;
23 24 import java.util.concurrent.Callable;
24 25 import java.util.concurrent.ConcurrentHashMap;
25 26 import java.util.concurrent.Future;
... ... @@ -41,9 +42,11 @@ public class LayeringCache extends RedisCache {
41 42 public LayeringCache(LayeringCacheManager layeringCacheManager, String name, RedisCacheWriter cacheWriter, RedisCacheConfiguration cacheConfig) {
42 43 super(name, cacheWriter, cacheConfig);
43 44 this.layeringCacheManager = layeringCacheManager;
44   -
45 45 this.layeringCacheProperties = layeringCacheManager.getLayeringCacheProperties();
46   - this.layerL1Enable = layeringCacheProperties.getCacheL1().isEnable();
  46 + this.layerL1Enable =
  47 + Optional.ofNullable(layeringCacheProperties.getCacheL1())
  48 + .orElse(new LayeringCacheProperties.L1())
  49 + .isEnable();
47 50  
48 51 initEhcache();
49 52 }
... ...