mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 14:35:45 +01:00
Use cache with size zero to avoid null checks
This commit is contained in:
@@ -81,9 +81,9 @@ public class DefaultUberWebResourceLoader implements UberWebResourceLoader
|
|||||||
this.cache = createCache(stage);
|
this.cache = createCache(stage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Cache<String, URL> createCache(Stage stage) {
|
private Cache<String, URL> createCache(Stage stage) {
|
||||||
if (stage == Stage.DEVELOPMENT) {
|
if (stage == Stage.DEVELOPMENT) {
|
||||||
return null;
|
return CacheBuilder.newBuilder().maximumSize(0).build(); // Disable caching
|
||||||
}
|
}
|
||||||
return CacheBuilder.newBuilder().build();
|
return CacheBuilder.newBuilder().build();
|
||||||
}
|
}
|
||||||
@@ -121,16 +121,11 @@ public class DefaultUberWebResourceLoader implements UberWebResourceLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
private URL getFromCache(String path) {
|
private URL getFromCache(String path) {
|
||||||
if (cache != null) {
|
return cache.getIfPresent(path);
|
||||||
return cache.getIfPresent(path);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addToCache(String path, URL url) {
|
private void addToCache(String path, URL url) {
|
||||||
if (cache != null) {
|
cache.put(path, url);
|
||||||
cache.put(path, url);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user