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);
    }
}
This commit is contained in:
Njal Karevoll 2012-11-07 15:39:47 +01:00 committed by Shay Banon
parent 91de48d2d3
commit f33e353259
1 changed files with 1 additions and 1 deletions

View File

@ -209,6 +209,7 @@ public class RestController extends AbstractLifecycleComponent<RestController> {
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<RestController> {
RestFilter preProcessor = filters[loc];
preProcessor.process(request, channel, this);
}
index++;
} catch (Exception e) {
try {
channel.sendResponse(new XContentThrowableRestResponse(request, e));