Skip to content

Commit

Permalink
Sonar issues fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Jareš <[email protected]>
  • Loading branch information
pj892031 committed Sep 22, 2023
1 parent 62d4f9d commit 5de0040
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void evictSubset(CacheManager cacheManager, String cacheName, Predicate<C
Spliterator<javax.cache.Cache.Entry<Object, Object>> spliterator = ((javax.cache.Cache<Object, Object>) nativeCache).spliterator();
Set<Object> keysToRemove = StreamSupport.stream(spliterator, true)
.filter(e -> !(e.getKey() instanceof CompositeKey) || keyPredicate.test((CompositeKey) e.getKey()))
.map(e -> e.getKey())
.map(javax.cache.Cache.Entry::getKey)
.collect(Collectors.toSet());
((javax.cache.Cache<Object, Object>) nativeCache).removeAll(keysToRemove);
} else {
Expand All @@ -92,7 +92,7 @@ public <T> List<T> getAllRecords(CacheManager cacheManager, String cacheName) {
final Object nativeCache = cache.getNativeCache();
if (nativeCache instanceof javax.cache.Cache) {
Spliterator<javax.cache.Cache.Entry<Object, T>> spliterator = ((javax.cache.Cache<Object, T>) nativeCache).spliterator();
return StreamSupport.stream(spliterator, true).map(e -> e.getValue()).collect(Collectors.toList());
return StreamSupport.stream(spliterator, true).map(javax.cache.Cache.Entry::getValue).collect(Collectors.toList());
} else {
throw new IllegalArgumentException("Unsupported type of cache : " + nativeCache.getClass());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.zowe.apiml.util.CacheUtils;

import javax.annotation.PostConstruct;
import java.io.IOException;

/**
* Spring configuration to use EhCache. This context is using from application and also from tests.
Expand All @@ -48,14 +49,14 @@ public void afterPropertiesSet() {
}

@Bean
public JCacheManagerFactoryBean cacheManagerFactoryBean() throws Exception {
public JCacheManagerFactoryBean cacheManagerFactoryBean() throws IOException {
JCacheManagerFactoryBean jCacheManagerFactoryBean = new JCacheManagerFactoryBean();
jCacheManagerFactoryBean.setCacheManagerUri(new ClassPathResource("ehcache.xml").getURI());
return jCacheManagerFactoryBean;
}

@Bean
public CacheManager cacheManager() throws Exception {
public CacheManager cacheManager() throws IOException {
final JCacheCacheManager jCacheCacheManager = new JCacheCacheManager();
jCacheCacheManager.setCacheManager(cacheManagerFactoryBean().getObject());
return jCacheCacheManager;
Expand Down

0 comments on commit 5de0040

Please sign in to comment.