aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-home/src
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-home/src')
-rw-r--r--sonar-home/src/main/java/org/sonar/home/cache/PersistentCache.java4
-rw-r--r--sonar-home/src/test/java/org/sonar/home/cache/PersistentCacheTest.java7
2 files changed, 9 insertions, 2 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 2193f5a1ba4..c5c45090ed4 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
@@ -76,7 +76,9 @@ public class PersistentCache {
@CheckForNull
public synchronized String getString(@Nonnull String obj, @Nullable final PersistentCacheLoader<String> valueLoader) throws IOException {
- byte[] cached = get(obj, new ValueLoaderDecoder(valueLoader));
+ ValueLoaderDecoder decoder = valueLoader != null ? new ValueLoaderDecoder(valueLoader) : null;
+
+ byte[] cached = get(obj, decoder);
if (cached == null) {
return null;
diff --git a/sonar-home/src/test/java/org/sonar/home/cache/PersistentCacheTest.java b/sonar-home/src/test/java/org/sonar/home/cache/PersistentCacheTest.java
index 72f594bf7d1..9760b096676 100644
--- a/sonar-home/src/test/java/org/sonar/home/cache/PersistentCacheTest.java
+++ b/sonar-home/src/test/java/org/sonar/home/cache/PersistentCacheTest.java
@@ -20,7 +20,6 @@
package org.sonar.home.cache;
import java.io.File;
-import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.junit.Before;
@@ -55,6 +54,12 @@ public class PersistentCacheTest {
assertThat(cache.get(URI, null)).isNull();
assertCacheHit(false);
}
+
+ @Test
+ public void testNullLoaderString() throws Exception {
+ assertThat(cache.getString(URI, null)).isNull();
+ assertCacheHit(false);
+ }
@Test
public void testNullValue() throws Exception {