summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2021-05-27 15:52:14 +0200
committerHarald Musum <musum@verizonmedia.com>2021-05-27 15:52:14 +0200
commitecd7529d27b3083ea66f5dafc4ce1404b717e7c7 (patch)
treeedb962827f58b763fa51f4041befb6670995cb46 /configserver
parentbba2924a61ace954a7d61a4bbb66f21a4cc062af (diff)
Throw IllegalArgumentException for bad requests
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java2
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java4
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java6
3 files changed, 6 insertions, 6 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
index 52bb8442982..276eb51981c 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
@@ -994,7 +994,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
private Session validateThatLocalSessionIsNotActive(Tenant tenant, long sessionId) {
Session session = getLocalSession(tenant, sessionId);
if (Session.Status.ACTIVATE.equals(session.getStatus())) {
- throw new IllegalStateException("Session is active: " + sessionId);
+ throw new IllegalArgumentException("Session is active: " + sessionId);
}
return session;
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java
index 05e73e7f454..2d336267169 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java
@@ -189,9 +189,9 @@ public class Deployment implements com.yahoo.config.provision.Deployment {
private void validateSessionStatus(Session session) {
long sessionId = session.getSessionId();
if (Session.Status.NEW.equals(session.getStatus())) {
- throw new IllegalStateException(session.logPre() + "Session " + sessionId + " is not prepared");
+ throw new IllegalArgumentException(session.logPre() + "Session " + sessionId + " is not prepared");
} else if (Session.Status.ACTIVATE.equals(session.getStatus())) {
- throw new IllegalStateException(session.logPre() + "Session " + sessionId + " is already active");
+ throw new IllegalArgumentException(session.logPre() + "Session " + sessionId + " is already active");
}
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java
index eff663588a9..2cf4d7e7b69 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java
@@ -575,7 +575,7 @@ public class ApplicationRepositoryTest {
TimeoutBudget timeoutBudget = new TimeoutBudget(clock, Duration.ofSeconds(10));
long sessionId = applicationRepository.createSession(applicationId(), timeoutBudget, testAppJdiscOnly);
- exceptionRule.expect(IllegalStateException.class);
+ exceptionRule.expect(IllegalArgumentException.class);
exceptionRule.expectMessage(containsString("tenant:test1 Session 3 is not prepared"));
applicationRepository.activate(applicationRepository.getTenant(applicationId()), sessionId, timeoutBudget, false);
@@ -624,11 +624,11 @@ public class ApplicationRepositoryTest {
PrepareResult result = deployApp(testAppJdiscOnly);
long sessionId = result.sessionId();
- exceptionRule.expect(IllegalStateException.class);
+ exceptionRule.expect(IllegalArgumentException.class);
exceptionRule.expectMessage(containsString("Session is active: 2"));
applicationRepository.prepare(sessionId, prepareParams());
- exceptionRule.expect(IllegalStateException.class);
+ exceptionRule.expect(IllegalArgumentException.class);
exceptionRule.expectMessage(containsString("tenant:test1 app:testapp:default Session 2 is already active"));
applicationRepository.activate(applicationRepository.getTenant(applicationId()), sessionId, timeoutBudget, false);
}