From f33e35325975f9f4b5202e13ab17ae531454b610 Mon Sep 17 00:00:00 2001 From: Njal Karevoll Date: Wed, 7 Nov 2012 15:39:47 +0100 Subject: [PATCH] The index of the next RestFilter must be incremented before the current filter starts processing. Otherwise, synchronous filters will not work. For example, the following filter would cause a StackOverflowError: public class SimpleRestFilter extends RestFilter { @Override public void process(RestRequest request, RestChannel channel, RestFilterChain filterChain) { filterChain.continueProcessing(request, channel); } } --- src/main/java/org/elasticsearch/rest/RestController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/elasticsearch/rest/RestController.java b/src/main/java/org/elasticsearch/rest/RestController.java index e852e76c2f5..620c8229b25 100644 --- a/src/main/java/org/elasticsearch/rest/RestController.java +++ b/src/main/java/org/elasticsearch/rest/RestController.java @@ -209,6 +209,7 @@ public class RestController extends AbstractLifecycleComponent { public void continueProcessing(RestRequest request, RestChannel channel) { try { int loc = index; + index++; if (loc > filters.length) { throw new ElasticSearchIllegalStateException("filter continueProcessing was called more than expected"); } else if (loc == filters.length) { @@ -217,7 +218,6 @@ public class RestController extends AbstractLifecycleComponent { RestFilter preProcessor = filters[loc]; preProcessor.process(request, channel, this); } - index++; } catch (Exception e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e));