Skip to content

Commit

Permalink
fix tests and nits
Browse files Browse the repository at this point in the history
  • Loading branch information
jakelandis committed Sep 27, 2024
1 parent 7203962 commit 34a1479
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
38 changes: 24 additions & 14 deletions server/src/main/java/org/elasticsearch/rest/RestController.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,20 +163,22 @@ protected void registerAsDeprecatedHandler(
Level deprecationLevel
) {
assert (handler instanceof DeprecationRestHandler) == false;
registerHandler(
method,
path,
version,
new DeprecationRestHandler(
handler,
if (RestApiVersion.onOrAfter(RestApiVersion.minimumSupported()).test(version)) {
registerHandler(
method,
path,
deprecationLevel,
deprecationMessage,
deprecationLogger,
version != RestApiVersion.current()
)
);
version,
new DeprecationRestHandler(
handler,
method,
path,
deprecationLevel,
deprecationMessage,
deprecationLogger,
version != RestApiVersion.current()
)
);
}
}

/**
Expand Down Expand Up @@ -237,7 +239,15 @@ protected void registerHandler(RestRequest.Method method, String path, RestApiVe

private void registerHandlerNoWrap(RestRequest.Method method, String path, RestApiVersion version, RestHandler handler) {
assert RestApiVersion.minimumSupported() == version || RestApiVersion.current() == version
: "REST API compatibility is only supported for version " + RestApiVersion.minimumSupported().major;
: "REST API compatibility is only supported for version "
+ RestApiVersion.minimumSupported().major
+ " [method="
+ method
+ ", path="
+ path
+ ", handler="
+ handler.getClass().getCanonicalName()
+ "]";

if (RESERVED_PATHS.contains(path)) {
throw new IllegalArgumentException("path [" + path + "] is a reserved path and may not be registered");
Expand All @@ -252,7 +262,7 @@ private void registerHandlerNoWrap(RestRequest.Method method, String path, RestA
}

public void registerHandler(final Route route, final RestHandler handler) {
if (route.isReplacement()) {
if (route.hasReplacement()) {
Route replaced = route.getReplacedRoute();
registerAsReplacedHandler(
route.getMethod(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ public Route getReplacedRoute() {
return replacedRoute;
}

public boolean isReplacement() {
public boolean hasReplacement() {
return replacedRoute != null;
}
}
Expand Down

0 comments on commit 34a1479

Please sign in to comment.