From 803ad18d6ebdeae9878b61d4f2e7270b68fba370 Mon Sep 17 00:00:00 2001 From: Jonathan Smith Date: Fri, 26 Jul 2024 16:04:07 +1200 Subject: [PATCH] Rename catchAllErrorHandler to uncaughtErrorHandler --- .../main/java/io/vertx/ext/web/Router.java | 2 +- .../io/vertx/ext/web/impl/RouterImpl.java | 4 +-- .../io/vertx/ext/web/impl/RouterState.java | 33 ++++++++++--------- .../java/io/vertx/ext/web/RouterTest.java | 4 +-- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/vertx-web/src/main/java/io/vertx/ext/web/Router.java b/vertx-web/src/main/java/io/vertx/ext/web/Router.java index f3a6bc24b5..7a9d73b89f 100644 --- a/vertx-web/src/main/java/io/vertx/ext/web/Router.java +++ b/vertx-web/src/main/java/io/vertx/ext/web/Router.java @@ -382,7 +382,7 @@ static Router router(Vertx vertx) { * @return a reference to this, so the API can be used fluently */ @Fluent - Router catchAllErrorHandler(Handler errorHandler); + Router uncaughtErrorHandler(Handler errorHandler); /** * Used to route a context to the router. Used for sub-routers. You wouldn't normally call this method directly. diff --git a/vertx-web/src/main/java/io/vertx/ext/web/impl/RouterImpl.java b/vertx-web/src/main/java/io/vertx/ext/web/impl/RouterImpl.java index 54ce2347d1..f2443e25ae 100644 --- a/vertx-web/src/main/java/io/vertx/ext/web/impl/RouterImpl.java +++ b/vertx-web/src/main/java/io/vertx/ext/web/impl/RouterImpl.java @@ -297,8 +297,8 @@ public synchronized Router errorHandler(int statusCode, Handler } @Override - public synchronized Router catchAllErrorHandler(Handler errorHandler) { - state = state.setCatchAllErrorHandler(errorHandler); + public synchronized Router uncaughtErrorHandler(Handler errorHandler) { + state = state.setUncaughtErrorHandler(errorHandler); return this; } diff --git a/vertx-web/src/main/java/io/vertx/ext/web/impl/RouterState.java b/vertx-web/src/main/java/io/vertx/ext/web/impl/RouterState.java index 51cc8a6ac5..e7e4f625b5 100644 --- a/vertx-web/src/main/java/io/vertx/ext/web/impl/RouterState.java +++ b/vertx-web/src/main/java/io/vertx/ext/web/impl/RouterState.java @@ -57,17 +57,17 @@ final class RouterState { private final TreeSet routes; private final int orderSequence; private final Map> errorHandlers; - private final Handler catchAllErrorHandler; + private final Handler uncaughtErrorHandler; private final Handler modifiedHandler; private final AllowForwardHeaders allowForward; private final Map metadata; - public RouterState(RouterImpl router, TreeSet routes, int orderSequence, Map> errorHandlers, final Handler catchAllErrorHandler, Handler modifiedHandler, AllowForwardHeaders allowForward, Map metadata) { + public RouterState(RouterImpl router, TreeSet routes, int orderSequence, Map> errorHandlers, final Handler uncaughtErrorHandler, Handler modifiedHandler, AllowForwardHeaders allowForward, Map metadata) { this.router = router; this.routes = routes; this.orderSequence = orderSequence; this.errorHandlers = errorHandlers; - this.catchAllErrorHandler = catchAllErrorHandler; + this.uncaughtErrorHandler = uncaughtErrorHandler; this.modifiedHandler = modifiedHandler; this.allowForward = allowForward; this.metadata = metadata; @@ -102,7 +102,7 @@ RouterState setRoutes(Set routes) { new TreeSet<>(routeComparator), this.orderSequence, this.errorHandlers, - this.catchAllErrorHandler, + this.uncaughtErrorHandler, this.modifiedHandler, this.allowForward, this.metadata); @@ -123,7 +123,7 @@ RouterState addRoute(RouteImpl route) { routes, this.orderSequence, this.errorHandlers, - this.catchAllErrorHandler, + this.uncaughtErrorHandler, this.modifiedHandler, this.allowForward, this.metadata); @@ -135,7 +135,8 @@ RouterState clearRoutes() { new TreeSet<>(routeComparator), this.orderSequence, this.errorHandlers, - null, this.modifiedHandler, + null, + this.modifiedHandler, this.allowForward, this.metadata); } @@ -152,7 +153,7 @@ RouterState removeRoute(RouteImpl route) { routes, this.orderSequence, this.errorHandlers, - this.catchAllErrorHandler, + this.uncaughtErrorHandler, this.modifiedHandler, this.allowForward, this.metadata); @@ -168,7 +169,7 @@ RouterState incrementOrderSequence() { this.routes, this.orderSequence + 1, this.errorHandlers, - this.catchAllErrorHandler, + this.uncaughtErrorHandler, this.modifiedHandler, this.allowForward, this.metadata); @@ -180,7 +181,7 @@ RouterState setOrderSequence(int orderSequence) { this.routes, orderSequence, this.errorHandlers, - this.catchAllErrorHandler, + this.uncaughtErrorHandler, this.modifiedHandler, this.allowForward, this.metadata); @@ -196,7 +197,7 @@ RouterState setErrorHandlers(Map> errorHandlers this.routes, this.orderSequence, errorHandlers, - this.catchAllErrorHandler, + this.uncaughtErrorHandler, this.modifiedHandler, this.allowForward, this.metadata); @@ -209,7 +210,7 @@ Handler getErrorHandler(int errorCode) { return errorHandler; } } - return catchAllErrorHandler; + return uncaughtErrorHandler; } RouterState putErrorHandler(int errorCode, Handler errorHandler) { @@ -218,7 +219,7 @@ RouterState putErrorHandler(int errorCode, Handler errorHandler) this.routes, this.orderSequence, this.errorHandlers == null ? new HashMap<>() : new HashMap<>(errorHandlers), - this.catchAllErrorHandler, + this.uncaughtErrorHandler, this.modifiedHandler, this.allowForward, this.metadata); @@ -227,7 +228,7 @@ RouterState putErrorHandler(int errorCode, Handler errorHandler) return newState; } - RouterState setCatchAllErrorHandler(Handler errorHandler) { + RouterState setUncaughtErrorHandler(Handler errorHandler) { return new RouterState( this.router, this.routes, @@ -249,7 +250,7 @@ public RouterState setModifiedHandler(Handler modifiedHandler) { this.routes, this.orderSequence, this.errorHandlers, - this.catchAllErrorHandler, + this.uncaughtErrorHandler, modifiedHandler, this.allowForward, this.metadata); @@ -261,7 +262,7 @@ public RouterState setAllowForward(AllowForwardHeaders allow) { this.routes, this.orderSequence, this.errorHandlers, - this.catchAllErrorHandler, + this.uncaughtErrorHandler, this.modifiedHandler, allow, this.metadata); @@ -283,7 +284,7 @@ public RouterState putMetadata(String key, Object value) { this.routes, this.orderSequence, this.errorHandlers, - this.catchAllErrorHandler, + this.uncaughtErrorHandler, this.modifiedHandler, this.allowForward, Collections.unmodifiableMap(metadata)); diff --git a/vertx-web/src/test/java/io/vertx/ext/web/RouterTest.java b/vertx-web/src/test/java/io/vertx/ext/web/RouterTest.java index da62ef2ab4..2540b06e1d 100644 --- a/vertx-web/src/test/java/io/vertx/ext/web/RouterTest.java +++ b/vertx-web/src/test/java/io/vertx/ext/web/RouterTest.java @@ -3647,9 +3647,9 @@ public void testExtractCallee() throws Exception { } @Test - public void testCatchAllErrorHandler() throws Exception { + public void testUncaughtErrorHandler() throws Exception { router.route().consumes("text/html").handler(rc -> rc.response().end()); - router.catchAllErrorHandler(context -> context.response().setStatusCode(context.statusCode()).setStatusMessage("Dumb").end()); + router.uncaughtErrorHandler(context -> context.response().setStatusCode(context.statusCode()).setStatusMessage("Dumb").end()); testRequestWithContentType(HttpMethod.GET, "/foo", "something/html", 415, "Dumb"); }