aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-home
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2015-08-04 13:59:33 +0200
committerDuarte Meneses <duarte.meneses@sonarsource.com>2015-08-04 13:59:51 +0200
commit39bc3790a7551a188a22eb9d8beb4b54863660c0 (patch)
tree323d3e35e988e0e66cd9ccf0a3357ea122be2a46 /sonar-home
parentcea0e9a4be612c196fc50765a2d28303027ddf3b (diff)
downloadsonarqube-39bc3790a7551a188a22eb9d8beb4b54863660c0.tar.gz
sonarqube-39bc3790a7551a188a22eb9d8beb4b54863660c0.zip
Improve quality
Diffstat (limited to 'sonar-home')
-rw-r--r--sonar-home/src/main/java/org/sonar/home/cache/PersistentCache.java28
1 files changed, 18 insertions, 10 deletions
diff --git a/sonar-home/src/main/java/org/sonar/home/cache/PersistentCache.java b/sonar-home/src/main/java/org/sonar/home/cache/PersistentCache.java
index b8fdca5d1d5..918f2b1a147 100644
--- a/sonar-home/src/main/java/org/sonar/home/cache/PersistentCache.java
+++ b/sonar-home/src/main/java/org/sonar/home/cache/PersistentCache.java
@@ -77,16 +77,7 @@ public class PersistentCache {
@CheckForNull
public synchronized String getString(@Nonnull String obj, @Nullable final PersistentCacheLoader<String> valueLoader) throws IOException {
- byte[] cached = get(obj, new PersistentCacheLoader<byte[]>() {
- @Override
- public byte[] get() throws IOException {
- String s = valueLoader.get();
- if (s != null) {
- return s.getBytes(ENCODING);
- }
- return null;
- }
- });
+ byte[] cached = get(obj, new ValueLoaderDecoder(valueLoader));
if (cached == null) {
return null;
@@ -229,6 +220,23 @@ public class PersistentCache {
}
}
+ private static class ValueLoaderDecoder implements PersistentCacheLoader<byte[]> {
+ PersistentCacheLoader<String> valueLoader;
+
+ ValueLoaderDecoder(PersistentCacheLoader<String> valueLoader) {
+ this.valueLoader = valueLoader;
+ }
+
+ @Override
+ public byte[] get() throws IOException {
+ String s = valueLoader.get();
+ if (s != null) {
+ return s.getBytes(ENCODING);
+ }
+ return null;
+ }
+ }
+
private static class DirectoryClearFilter implements DirectoryStream.Filter<Path> {
@Override
public boolean accept(Path entry) throws IOException {