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:
parent
91de48d2d3
commit
f33e353259
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue