From 39bc3790a7551a188a22eb9d8beb4b54863660c0 Mon Sep 17 00:00:00 2001 From: Duarte Meneses Date: Tue, 4 Aug 2015 13:59:33 +0200 Subject: Improve quality --- .../java/org/sonar/home/cache/PersistentCache.java | 28 ++++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'sonar-home') 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 valueLoader) throws IOException { - byte[] cached = get(obj, new PersistentCacheLoader() { - @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 { + PersistentCacheLoader valueLoader; + + ValueLoaderDecoder(PersistentCacheLoader 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 { @Override public boolean accept(Path entry) throws IOException { -- cgit v1.2.3