diff options
3 files changed, 8 insertions, 8 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(); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java index e0f25637bcf..084cabc0d63 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java @@ -404,5 +404,5 @@ public interface CoreProperties { /** * @since 3.7 */ - String DRY_RUN_READ_TIMEOUT = "sonar.dryRun.readTimeout"; + String DRY_RUN_READ_TIMEOUT_SEC = "sonar.dryRun.readTimeout"; } |