aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-main/src/main/java
diff options
context:
space:
mode:
authorMatteo Mara <matteo.mara@sonarsource.com>2023-01-06 12:59:21 +0100
committersonartech <sonartech@sonarsource.com>2023-01-10 20:03:01 +0000
commit18f91c25d369917f3a99841f6bb31b94a02467fc (patch)
tree9939b8dfb10c74b95a5addbcadb8fb91ba296f31 /server/sonar-main/src/main/java
parent215dd7343dc55f91613b820d43c208c19a50d176 (diff)
downloadsonarqube-18f91c25d369917f3a99841f6bb31b94a02467fc.tar.gz
sonarqube-18f91c25d369917f3a99841f6bb31b94a02467fc.zip
[NO-JIRA] Remove reported code smells about switch statements
Diffstat (limited to 'server/sonar-main/src/main/java')
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/SchedulerImpl.java20
1 files changed, 7 insertions, 13 deletions
diff --git a/server/sonar-main/src/main/java/org/sonar/application/SchedulerImpl.java b/server/sonar-main/src/main/java/org/sonar/application/SchedulerImpl.java
index 9b1a45643cf..ca6fe276c4b 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/SchedulerImpl.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/SchedulerImpl.java
@@ -114,17 +114,12 @@ public class SchedulerImpl implements Scheduler, ManagedProcessEventListener, Pr
}
private static ManagedProcessHandler.Timeout stopTimeoutFor(ProcessId processId, AppSettings settings) {
- switch (processId) {
- case ELASTICSEARCH:
- return HARD_STOP_TIMEOUT;
- case WEB_SERVER:
- return newTimeout(getStopTimeoutMs(settings, WEB_GRACEFUL_STOP_TIMEOUT), TimeUnit.MILLISECONDS);
- case COMPUTE_ENGINE:
- return newTimeout(getStopTimeoutMs(settings, CE_GRACEFUL_STOP_TIMEOUT), TimeUnit.MILLISECONDS);
- case APP:
- default:
- throw new IllegalArgumentException("Unsupported processId " + processId);
- }
+ return switch (processId) {
+ case ELASTICSEARCH -> HARD_STOP_TIMEOUT;
+ case WEB_SERVER -> newTimeout(getStopTimeoutMs(settings, WEB_GRACEFUL_STOP_TIMEOUT), TimeUnit.MILLISECONDS);
+ case COMPUTE_ENGINE -> newTimeout(getStopTimeoutMs(settings, CE_GRACEFUL_STOP_TIMEOUT), TimeUnit.MILLISECONDS);
+ default -> throw new IllegalArgumentException("Unsupported processId " + processId);
+ };
}
private static long getStopTimeoutMs(AppSettings settings, ProcessProperties.Property property) {
@@ -385,8 +380,7 @@ public class SchedulerImpl implements Scheduler, ManagedProcessEventListener, Pr
restartAsync();
}
break;
- case HARD_STOPPING:
- case STOPPING:
+ case HARD_STOPPING, STOPPING:
if (lastProcessStopped) {
finalizeStop();
}