From 095cbd02e5bd11fd9adc88410166b75bfd41fd6f Mon Sep 17 00:00:00 2001 From: Amnon Heiman Date: Tue, 18 Jun 2019 16:53:12 +0300 Subject: [PATCH] APIClient: delete command should check for errors delete commands do not return a value, still, it is possible that the command will return a value different than OK. In such a case, the error should be propagate to the caller via an exception. Fixes #65 Signed-off-by: Amnon Heiman Message-Id: <20190618135312.2776-1-amnon@scylladb.com> (cherry picked from commit 2fac82434bc8985bb150bc203a24fd3cc2181675) --- src/main/java/com/scylladb/jmx/api/APIClient.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/scylladb/jmx/api/APIClient.java b/src/main/java/com/scylladb/jmx/api/APIClient.java index b893695..86ae4f4 100644 --- a/src/main/java/com/scylladb/jmx/api/APIClient.java +++ b/src/main/java/com/scylladb/jmx/api/APIClient.java @@ -152,7 +152,11 @@ public class APIClient { get(path, queryParams).delete(); return; } - get(path).delete(); + Response response = get(path).delete(); + if (response.getStatus() != Response.Status.OK.getStatusCode()) { + throw getException("Scylla API server HTTP delete to URL '" + path + "' failed", + response.readEntity(String.class)); + } } public void delete(String path) {