|
@@ -77,29 +77,21 @@ public class ConfigFileController implements ReleaseMessageListener {
|
|
|
final GrayReleaseRulesHolder grayReleaseRulesHolder) {
|
|
|
localCache = CacheBuilder.newBuilder()
|
|
|
.expireAfterWrite(EXPIRE_AFTER_WRITE, TimeUnit.MINUTES)
|
|
|
- .weigher(new Weigher<String, String>() {
|
|
|
- @Override
|
|
|
- public int weigh(String key, String value) {
|
|
|
- return value == null ? 0 : value.length();
|
|
|
- }
|
|
|
- })
|
|
|
+ .weigher((Weigher<String, String>) (key, value) -> value == null ? 0 : value.length())
|
|
|
.maximumWeight(MAX_CACHE_SIZE)
|
|
|
- .removalListener(new RemovalListener<String, String>() {
|
|
|
- @Override
|
|
|
- public void onRemoval(RemovalNotification<String, String> notification) {
|
|
|
- String cacheKey = notification.getKey();
|
|
|
- logger.debug("removing cache key: {}", cacheKey);
|
|
|
- if (!cacheKey2WatchedKeys.containsKey(cacheKey)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- //create a new list to avoid ConcurrentModificationException
|
|
|
- List<String> watchedKeys = new ArrayList<>(cacheKey2WatchedKeys.get(cacheKey));
|
|
|
- for (String watchedKey : watchedKeys) {
|
|
|
- watchedKeys2CacheKey.remove(watchedKey, cacheKey);
|
|
|
- }
|
|
|
- cacheKey2WatchedKeys.removeAll(cacheKey);
|
|
|
- logger.debug("removed cache key: {}", cacheKey);
|
|
|
+ .removalListener(notification -> {
|
|
|
+ String cacheKey = notification.getKey();
|
|
|
+ logger.debug("removing cache key: {}", cacheKey);
|
|
|
+ if (!cacheKey2WatchedKeys.containsKey(cacheKey)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //create a new list to avoid ConcurrentModificationException
|
|
|
+ List<String> watchedKeys = new ArrayList<>(cacheKey2WatchedKeys.get(cacheKey));
|
|
|
+ for (String watchedKey : watchedKeys) {
|
|
|
+ watchedKeys2CacheKey.remove(watchedKey, cacheKey);
|
|
|
}
|
|
|
+ cacheKey2WatchedKeys.removeAll(cacheKey);
|
|
|
+ logger.debug("removed cache key: {}", cacheKey);
|
|
|
})
|
|
|
.build();
|
|
|
propertiesResponseHeaders = new HttpHeaders();
|