-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce FilterRestHandler (#98922)
RestHandler has a number of methods that affect the behaviour of request processing. If the handler is wrapped (e.g. SecurityRestFilter or DeprecationRestHandler) then these methods must be delegated to the underlying handler. This commit introduces a new abstract base class `FilterRestHandler` that correctly delegates these methods so that wrappers (subclasses) do not need to implement the behaviour on a case-by-case basis Backport of: #98861
- Loading branch information
Showing
5 changed files
with
78 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
server/src/main/java/org/elasticsearch/rest/FilterRestHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.rest; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
public abstract class FilterRestHandler implements RestHandler { | ||
private final RestHandler delegate; | ||
|
||
protected FilterRestHandler(RestHandler delegate) { | ||
this.delegate = Objects.requireNonNull(delegate); | ||
} | ||
|
||
protected RestHandler getDelegate() { | ||
return delegate; | ||
} | ||
|
||
@Override | ||
public RestHandler getConcreteRestHandler() { | ||
return delegate.getConcreteRestHandler(); | ||
} | ||
|
||
@Override | ||
public List<RestHandler.Route> routes() { | ||
return delegate.routes(); | ||
} | ||
|
||
@Override | ||
public boolean allowSystemIndexAccessByDefault() { | ||
return delegate.allowSystemIndexAccessByDefault(); | ||
} | ||
|
||
@Override | ||
public boolean canTripCircuitBreaker() { | ||
return delegate.canTripCircuitBreaker(); | ||
} | ||
|
||
@Override | ||
public boolean allowsUnsafeBuffers() { | ||
return delegate.allowsUnsafeBuffers(); | ||
} | ||
|
||
@Override | ||
public boolean supportsContentStream() { | ||
return delegate.supportsContentStream(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters