From e1a16a601840f271ee2092fd4ea0ec111a6e97b3 Mon Sep 17 00:00:00 2001 From: Alexander Reelsen Date: Fri, 27 Apr 2018 08:41:36 +0200 Subject: [PATCH] REST: Remove GET support for clear cache indices (#29525) Clearing the cache indices can be done via GET and POST. As GET should only support read only operations, this removes the support for using GET for clearing the indices caches. --- docs/reference/release-notes/7.0.0-alpha1.asciidoc | 5 ++++- .../resources/rest-api-spec/api/indices.clear_cache.json | 2 +- .../action/admin/indices/RestClearIndicesCacheAction.java | 4 ---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/reference/release-notes/7.0.0-alpha1.asciidoc b/docs/reference/release-notes/7.0.0-alpha1.asciidoc index 128a9b7dd716b..618d9e70dcb30 100644 --- a/docs/reference/release-notes/7.0.0-alpha1.asciidoc +++ b/docs/reference/release-notes/7.0.0-alpha1.asciidoc @@ -8,4 +8,7 @@ The changes listed below have been released for the first time in Elasticsearch === Breaking changes Core:: -* Tribe node has been removed in favor of Cross-Cluster-Search \ No newline at end of file +* Tribe node has been removed in favor of Cross-Cluster-Search + +Rest API:: +* The Clear Cache API only supports `POST` as HTTP method diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.clear_cache.json b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.clear_cache.json index 9a0f7be1d65ae..7e62371dd674d 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.clear_cache.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.clear_cache.json @@ -1,7 +1,7 @@ { "indices.clear_cache": { "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-clearcache.html", - "methods": ["POST", "GET"], + "methods": ["POST"], "url": { "path": "/_cache/clear", "paths": ["/_cache/clear", "/{index}/_cache/clear"], diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestClearIndicesCacheAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestClearIndicesCacheAction.java index 266c1cb68f03f..38b9d987d04e5 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestClearIndicesCacheAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestClearIndicesCacheAction.java @@ -31,7 +31,6 @@ import java.io.IOException; -import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestClearIndicesCacheAction extends BaseRestHandler { @@ -40,9 +39,6 @@ public RestClearIndicesCacheAction(Settings settings, RestController controller) super(settings); controller.registerHandler(POST, "/_cache/clear", this); controller.registerHandler(POST, "/{index}/_cache/clear", this); - - controller.registerHandler(GET, "/_cache/clear", this); - controller.registerHandler(GET, "/{index}/_cache/clear", this); } @Override