aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-home/src
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2015-09-29 14:43:50 +0200
committerDuarte Meneses <duarte.meneses@sonarsource.com>2015-09-30 16:28:08 +0200
commit9ee1c1e3ba2be613b41807e119ae9f819aa7952b (patch)
treeff422adea1e7b1156abbe90dc3e171fc9d0d8179 /sonar-home/src
parent91cf8cfa5a50c8322b39f87c4cf187690af88d99 (diff)
downloadsonarqube-9ee1c1e3ba2be613b41807e119ae9f819aa7952b.tar.gz
sonarqube-9ee1c1e3ba2be613b41807e119ae9f819aa7952b.zip
Dont use server version in global cache keys
Diffstat (limited to 'sonar-home/src')
-rw-r--r--sonar-home/src/main/java/org/sonar/home/cache/PersistentCacheBuilder.java10
-rw-r--r--sonar-home/src/test/java/org/sonar/home/cache/PersistentCacheBuilderTest.java16
2 files changed, 14 insertions, 12 deletions
diff --git a/sonar-home/src/main/java/org/sonar/home/cache/PersistentCacheBuilder.java b/sonar-home/src/main/java/org/sonar/home/cache/PersistentCacheBuilder.java
index 2097832853b..7be8fae66e8 100644
--- a/sonar-home/src/main/java/org/sonar/home/cache/PersistentCacheBuilder.java
+++ b/sonar-home/src/main/java/org/sonar/home/cache/PersistentCacheBuilder.java
@@ -49,20 +49,22 @@ public class PersistentCacheBuilder {
}
public PersistentCacheBuilder setAreaForProject(String serverUrl, String serverVersion, String projectKey) {
- relativePath = Paths.get(sanitizeFilename(serverUrl + "-" + serverVersion))
+ relativePath = Paths.get(sanitizeFilename(serverUrl))
+ .resolve(sanitizeFilename(serverVersion))
.resolve("projects")
.resolve(sanitizeFilename(projectKey));
return this;
}
- public PersistentCacheBuilder setAreaForGlobal(String serverUrl, String serverVersion) {
- relativePath = Paths.get(sanitizeFilename(serverUrl + "-" + serverVersion))
+ public PersistentCacheBuilder setAreaForGlobal(String serverUrl) {
+ relativePath = Paths.get(sanitizeFilename(serverUrl))
.resolve("global");
return this;
}
public PersistentCacheBuilder setAreaForLocalProject(String serverUrl, String serverVersion) {
- relativePath = Paths.get(sanitizeFilename(serverUrl + "-" + serverVersion))
+ relativePath = Paths.get(sanitizeFilename(serverUrl))
+ .resolve(sanitizeFilename(serverVersion))
.resolve("local");
return this;
}
diff --git a/sonar-home/src/test/java/org/sonar/home/cache/PersistentCacheBuilderTest.java b/sonar-home/src/test/java/org/sonar/home/cache/PersistentCacheBuilderTest.java
index 7a57e98d68c..4ce016dd633 100644
--- a/sonar-home/src/test/java/org/sonar/home/cache/PersistentCacheBuilderTest.java
+++ b/sonar-home/src/test/java/org/sonar/home/cache/PersistentCacheBuilderTest.java
@@ -36,14 +36,14 @@ public class PersistentCacheBuilderTest {
@Test
public void user_home_property_can_be_null() {
- PersistentCache cache = new PersistentCacheBuilder(mock(Logger.class)).setSonarHome(null).setAreaForGlobal("url", "0").build();
+ PersistentCache cache = new PersistentCacheBuilder(mock(Logger.class)).setSonarHome(null).setAreaForGlobal("url").build();
assertTrue(Files.isDirectory(cache.getDirectory()));
- assertThat(cache.getDirectory()).endsWith(Paths.get("url-0", "global"));
+ assertThat(cache.getDirectory()).endsWith(Paths.get("url", "global"));
}
@Test
public void set_user_home() {
- PersistentCache cache = new PersistentCacheBuilder(mock(Logger.class)).setSonarHome(temp.getRoot().toPath()).setAreaForGlobal("url", "0").build();
+ PersistentCache cache = new PersistentCacheBuilder(mock(Logger.class)).setSonarHome(temp.getRoot().toPath()).setAreaForGlobal("url").build();
assertThat(cache.getDirectory()).isDirectory();
assertThat(cache.getDirectory()).startsWith(temp.getRoot().toPath());
@@ -56,7 +56,7 @@ public class PersistentCacheBuilderTest {
System.setProperty("user.home", temp.getRoot().getAbsolutePath());
- PersistentCache cache = new PersistentCacheBuilder(mock(Logger.class)).setAreaForGlobal("url", "0").build();
+ PersistentCache cache = new PersistentCacheBuilder(mock(Logger.class)).setAreaForGlobal("url").build();
assertTrue(Files.isDirectory(cache.getDirectory()));
assertThat(cache.getDirectory()).startsWith(temp.getRoot().toPath());
}
@@ -66,12 +66,12 @@ public class PersistentCacheBuilderTest {
System.setProperty("user.home", temp.getRoot().getAbsolutePath());
PersistentCache cache = new PersistentCacheBuilder(mock(Logger.class)).setAreaForProject("url", "0", "proj").build();
- assertThat(cache.getDirectory()).endsWith(Paths.get(".sonar", "ws_cache", "url-0", "projects", "proj"));
+ assertThat(cache.getDirectory()).endsWith(Paths.get(".sonar", "ws_cache", "url", "0", "projects", "proj"));
cache = new PersistentCacheBuilder(mock(Logger.class)).setAreaForLocalProject("url", "0").build();
- assertThat(cache.getDirectory()).endsWith(Paths.get(".sonar", "ws_cache", "url-0", "local"));
+ assertThat(cache.getDirectory()).endsWith(Paths.get(".sonar", "ws_cache", "url", "0", "local"));
- cache = new PersistentCacheBuilder(mock(Logger.class)).setAreaForGlobal("url", "0").build();
- assertThat(cache.getDirectory()).endsWith(Paths.get(".sonar", "ws_cache", "url-0", "global"));
+ cache = new PersistentCacheBuilder(mock(Logger.class)).setAreaForGlobal("url").build();
+ assertThat(cache.getDirectory()).endsWith(Paths.get(".sonar", "ws_cache", "url", "global"));
}
}