aboutsummaryrefslogtreecommitdiffstats
path: root/node-admin
diff options
context:
space:
mode:
authorHåkon Hallingstad <hakon@oath.com>2017-10-12 15:05:27 +0200
committerHåkon Hallingstad <hakon@oath.com>2017-10-12 15:05:27 +0200
commit9cc3de14e07a536f1b514df2467d6a40b938abac (patch)
tree15dfc9e67681dd319a7701803ede6a4a68e11fa9 /node-admin
parent8150638bfe1d663cc4fb42ef71a4a5f62880deec (diff)
Avoid HttpException on 409
Diffstat (limited to 'node-admin')
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/util/HttpException.java16
-rw-r--r--node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/util/ConfigServerHttpRequestExecutorTest.java13
2 files changed, 25 insertions, 4 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/util/HttpException.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/util/HttpException.java
index fd7f6308593..f4e8c63235d 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/util/HttpException.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/util/HttpException.java
@@ -18,10 +18,18 @@ public class HttpException extends RuntimeException {
throw new HttpException(statusCode, message);
}
- if (status == Response.Status.NOT_FOUND) {
- throw new NotFoundException(message);
- } else if (status.getFamily() != Response.Status.Family.SUCCESSFUL) {
- throw new HttpException(status, message);
+ if (status.getFamily() == Response.Status.Family.SUCCESSFUL) {
+ return;
+ }
+
+ switch (status) {
+ case NOT_FOUND: throw new NotFoundException(message);
+ case CONFLICT:
+ // A response body is assumed to be present, and
+ // will later be interpreted as an error.
+ return;
+ default:
+ throw new HttpException(status, message);
}
}
diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/util/ConfigServerHttpRequestExecutorTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/util/ConfigServerHttpRequestExecutorTest.java
index e197dd8bc54..21d53593b65 100644
--- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/util/ConfigServerHttpRequestExecutorTest.java
+++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/util/ConfigServerHttpRequestExecutorTest.java
@@ -143,6 +143,19 @@ public class ConfigServerHttpRequestExecutorTest {
assertLogStringContainsGETForAHost();
}
+ @Test
+ public void testConflict() throws Exception {
+ Set<String> configServers = new ArraySet<>(2);
+ configServers.add("host1");
+ configServers.add("host2");
+ // Server is returning 409, no exception is thrown.
+ mockReturnCode = 409;
+ ConfigServerHttpRequestExecutor executor =
+ new ConfigServerHttpRequestExecutor(configServers, createClientMock());
+ executor.get("/path", 666, TestPojo.class);
+ assertLogStringContainsGETForAHost();
+ }
+
private void assertLogStringContainsGETForAHost() {
String logString = mockLog.toString();
//assertThat(logString, startsWith("GET http://host"));