diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2013-07-15 14:59:16 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2013-07-15 14:59:16 +0200 |
commit | 31ebbfb9cef7a3259f99593d0be53474841cb42b (patch) | |
tree | d247e5d484b4e12d04e016fddd24b9e6f44da1d4 /sonar-batch | |
parent | 7a831a38975b83b0cbbf81dcbb9971e696935e2d (diff) | |
download | sonarqube-31ebbfb9cef7a3259f99593d0be53474841cb42b.tar.gz sonarqube-31ebbfb9cef7a3259f99593d0be53474841cb42b.zip |
SONAR-4488 Make sonar.dryRun.readTimeout property take seconds as input
Diffstat (limited to 'sonar-batch')
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/bootstrap/DryRunDatabase.java | 10 | ||||
-rw-r--r-- | sonar-batch/src/test/java/org/sonar/batch/bootstrap/DryRunDatabaseTest.java | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DryRunDatabase.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DryRunDatabase.java index 20a8d9ef8f2..9be2c5301a2 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DryRunDatabase.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DryRunDatabase.java @@ -46,7 +46,7 @@ public class DryRunDatabase implements BatchComponent { private static final String USER = "sonar"; private static final String PASSWORD = "sonar"; - private static final int DEFAULT_DRY_RUN_READ_TIMEOUT = 60 * 1000; + private static final int DEFAULT_DRY_RUN_READ_TIMEOUT_SEC = 60; private final Settings settings; private final ServerClient server; @@ -64,10 +64,10 @@ public class DryRunDatabase implements BatchComponent { File databaseFile = tempDirectories.getFile("", "dryrun.h2.db"); // SONAR-4488 Allow to increase dryRun timeout - int readTimeout = settings.getInt(CoreProperties.DRY_RUN_READ_TIMEOUT); - readTimeout = (readTimeout == 0) ? DEFAULT_DRY_RUN_READ_TIMEOUT : readTimeout; + int readTimeoutSec = settings.getInt(CoreProperties.DRY_RUN_READ_TIMEOUT_SEC); + readTimeoutSec = (readTimeoutSec == 0) ? DEFAULT_DRY_RUN_READ_TIMEOUT_SEC : readTimeoutSec; - downloadDatabase(databaseFile, readTimeout); + downloadDatabase(databaseFile, readTimeoutSec * 1000); String databasePath = StringUtils.removeEnd(databaseFile.getAbsolutePath(), ".h2.db"); replaceSettings(databasePath); @@ -99,7 +99,7 @@ public class DryRunDatabase implements BatchComponent { if (rootCause instanceof SocketTimeoutException) { // Pico will unwrap the first runtime exception throw new SonarException(new SonarException(String.format("DryRun database read timed out after %s ms. You can try to increase read timeout with property -D" - + CoreProperties.DRY_RUN_READ_TIMEOUT, + + CoreProperties.DRY_RUN_READ_TIMEOUT_SEC + "(in seconds)", readTimeout), e)); } if (projectKey != null && (rootCause instanceof HttpException) && (((HttpException) rootCause).getResponseCode() == 401)) { diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/DryRunDatabaseTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/DryRunDatabaseTest.java index 5e872ed0151..94935e8fa20 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/DryRunDatabaseTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/DryRunDatabaseTest.java @@ -79,7 +79,7 @@ public class DryRunDatabaseTest { @Test public void should_download_database_with_overriden_timeout() { - settings.setProperty(CoreProperties.DRY_RUN_READ_TIMEOUT, 80000); + settings.setProperty(CoreProperties.DRY_RUN_READ_TIMEOUT_SEC, 80); new DryRunDatabase(settings, server, tempDirectories).start(); verify(server).download("/batch_bootstrap/db?project=group:project", databaseFile, 80000); @@ -119,7 +119,7 @@ public class DryRunDatabaseTest { doThrow(new SonarException(new SocketTimeoutException())).when(server).download("/batch_bootstrap/db?project=group:project", databaseFile, 60000); thrown.expect(SonarException.class); - thrown.expectMessage("DryRun database read timed out after 60000 ms. You can try to increase read timeout with property -Dsonar.dryRun.readTimeout"); + thrown.expectMessage("DryRun database read timed out after 60000 ms. You can try to increase read timeout with property -Dsonar.dryRun.readTimeout (in seconds)"); new DryRunDatabase(settings, server, tempDirectories).start(); } |