From fe4f7ce5f43643a5e519ab62e2ea1f399ecf39e7 Mon Sep 17 00:00:00 2001 From: Tim Yates Date: Wed, 24 Jan 2024 11:27:29 +0000 Subject: [PATCH 1/2] Bump Micronaut to 4.3.0 and fix internal breakage --- gradle/libs.versions.toml | 2 +- .../java/io/micronaut/servlet/http/ServletHttpHandler.java | 6 +++--- .../server/tck/jetty/tests/JettyHttpServerTestSuite.java | 1 - .../server/tck/tomcat/tests/TomcatHttpServerTestSuite.java | 1 - .../tck/undertow/tests/UndertowHttpServerTestSuite.java | 1 - 5 files changed, 4 insertions(+), 7 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index cd337b09..92a65145 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -micronaut = "4.2.3" +micronaut = "4.3.0" micronaut-docs = "2.0.0" micronaut-test = "4.0.1" diff --git a/servlet-core/src/main/java/io/micronaut/servlet/http/ServletHttpHandler.java b/servlet-core/src/main/java/io/micronaut/servlet/http/ServletHttpHandler.java index f4f9eaf1..6aeec74f 100644 --- a/servlet-core/src/main/java/io/micronaut/servlet/http/ServletHttpHandler.java +++ b/servlet-core/src/main/java/io/micronaut/servlet/http/ServletHttpHandler.java @@ -210,7 +210,7 @@ public void service(ServletExchange exchange) { exchange.getRequest().executeAsync(asyncExecution -> { try (PropagatedContext.Scope ignore = PropagatedContext.getOrEmpty().plus(new ServerHttpRequestContext(req)).propagate()) { lc.handleNormal() - .onComplete((response, throwable) -> onComplete(exchange, req, response, throwable, httpResponse -> { + .onComplete((response, throwable) -> onComplete(exchange, req, response.toMutableResponse(), throwable, httpResponse -> { asyncExecution.complete(); requestTerminated.accept(httpResponse); })); @@ -222,7 +222,7 @@ public void service(ServletExchange exchange) { lc.handleNormal() .onComplete((response, throwable) -> { try { - onComplete(exchange, req, response, throwable, requestTerminated); + onComplete(exchange, req, response.toMutableResponse(), throwable, requestTerminated); } finally { termination.complete(null); } @@ -505,7 +505,7 @@ private final class ServletRequestLifecycle extends RequestLifecycle { super(routeExecutor, request); } - ExecutionFlow> handleNormal() { + ExecutionFlow> handleNormal() { return normalFlow(); } diff --git a/test-suite-http-server-tck-jetty/src/test/java/io/micronaut/http/server/tck/jetty/tests/JettyHttpServerTestSuite.java b/test-suite-http-server-tck-jetty/src/test/java/io/micronaut/http/server/tck/jetty/tests/JettyHttpServerTestSuite.java index 6232d9ef..49f25380 100644 --- a/test-suite-http-server-tck-jetty/src/test/java/io/micronaut/http/server/tck/jetty/tests/JettyHttpServerTestSuite.java +++ b/test-suite-http-server-tck-jetty/src/test/java/io/micronaut/http/server/tck/jetty/tests/JettyHttpServerTestSuite.java @@ -16,7 +16,6 @@ "io.micronaut.http.server.tck.tests.filter.ClientResponseFilterTest", // responseFilterThrowableParameter fails under Graal https://ge.micronaut.io/s/ufuhtbe5sgmxi "io.micronaut.http.server.tck.tests.FilterProxyTest", // see https://github.com/micronaut-projects/micronaut-core/issues/9725 "io.micronaut.http.server.tck.tests.LocalErrorReadingBodyTest", // Cannot read body as text once stream is exhausted trying to read it as a different type See https://github.com/micronaut-projects/micronaut-servlet/pull/548 - "io.micronaut.http.server.tck.tests.filter.options.OptionsFilterTest" // needs https://github.com/micronaut-projects/micronaut-core/pull/10126 }) public class JettyHttpServerTestSuite { } diff --git a/test-suite-http-server-tck-tomcat/src/test/java/io/micronaut/http/server/tck/tomcat/tests/TomcatHttpServerTestSuite.java b/test-suite-http-server-tck-tomcat/src/test/java/io/micronaut/http/server/tck/tomcat/tests/TomcatHttpServerTestSuite.java index 5065dd35..c2489fc1 100644 --- a/test-suite-http-server-tck-tomcat/src/test/java/io/micronaut/http/server/tck/tomcat/tests/TomcatHttpServerTestSuite.java +++ b/test-suite-http-server-tck-tomcat/src/test/java/io/micronaut/http/server/tck/tomcat/tests/TomcatHttpServerTestSuite.java @@ -13,7 +13,6 @@ "io.micronaut.http.server.tck.tests.filter.ClientResponseFilterTest", // responseFilterThrowableParameter fails under Graal https://ge.micronaut.io/s/ufuhtbe5sgmxi "io.micronaut.http.server.tck.tests.FilterProxyTest", // see https://github.com/micronaut-projects/micronaut-core/issues/9725 "io.micronaut.http.server.tck.tests.LocalErrorReadingBodyTest", // Cannot read body as text once stream is exhausted trying to read it as a different type See https://github.com/micronaut-projects/micronaut-servlet/pull/548 - "io.micronaut.http.server.tck.tests.filter.options.OptionsFilterTest" // needs https://github.com/micronaut-projects/micronaut-core/pull/10126 }) public class TomcatHttpServerTestSuite { } diff --git a/test-suite-http-server-tck-undertow/src/test/java/io/micronaut/http/server/tck/undertow/tests/UndertowHttpServerTestSuite.java b/test-suite-http-server-tck-undertow/src/test/java/io/micronaut/http/server/tck/undertow/tests/UndertowHttpServerTestSuite.java index ee34709a..2e507c78 100644 --- a/test-suite-http-server-tck-undertow/src/test/java/io/micronaut/http/server/tck/undertow/tests/UndertowHttpServerTestSuite.java +++ b/test-suite-http-server-tck-undertow/src/test/java/io/micronaut/http/server/tck/undertow/tests/UndertowHttpServerTestSuite.java @@ -15,7 +15,6 @@ "io.micronaut.http.server.tck.tests.StreamTest", // The outputstream in Undertow is marked ready asynchronously, and we throw the error early, so sometimes there's no body for statusErrorAsFirstItem. "io.micronaut.http.server.tck.tests.FilterProxyTest", // see https://github.com/micronaut-projects/micronaut-core/issues/9725 "io.micronaut.http.server.tck.tests.LocalErrorReadingBodyTest", // Cannot read body as text once stream is exhausted trying to read it as a different type See https://github.com/micronaut-projects/micronaut-servlet/pull/548 - "io.micronaut.http.server.tck.tests.filter.options.OptionsFilterTest" // needs https://github.com/micronaut-projects/micronaut-core/pull/10126 }) public class UndertowHttpServerTestSuite { } From 01e7fa676aad78c1e226ee7f800aeb90fe523032 Mon Sep 17 00:00:00 2001 From: Tim Yates Date: Wed, 24 Jan 2024 11:33:36 +0000 Subject: [PATCH 2/2] Stop using deprecated request lifecycle methods --- .../servlet/http/ServletHttpHandler.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/servlet-core/src/main/java/io/micronaut/servlet/http/ServletHttpHandler.java b/servlet-core/src/main/java/io/micronaut/servlet/http/ServletHttpHandler.java index 6aeec74f..18b186fb 100644 --- a/servlet-core/src/main/java/io/micronaut/servlet/http/ServletHttpHandler.java +++ b/servlet-core/src/main/java/io/micronaut/servlet/http/ServletHttpHandler.java @@ -204,12 +204,12 @@ public void service(ServletExchange exchange) { final HttpRequest req = exchange.getRequest(); applicationContext.publishEvent(new HttpRequestReceivedEvent(req)); - ServletRequestLifecycle lc = new ServletRequestLifecycle(routeExecutor, req); + ServletRequestLifecycle lc = new ServletRequestLifecycle(routeExecutor); if (exchange.getRequest().isAsyncSupported()) { exchange.getRequest().executeAsync(asyncExecution -> { try (PropagatedContext.Scope ignore = PropagatedContext.getOrEmpty().plus(new ServerHttpRequestContext(req)).propagate()) { - lc.handleNormal() + lc.handleNormal(req) .onComplete((response, throwable) -> onComplete(exchange, req, response.toMutableResponse(), throwable, httpResponse -> { asyncExecution.complete(); requestTerminated.accept(httpResponse); @@ -219,7 +219,7 @@ public void service(ServletExchange exchange) { } else { try (PropagatedContext.Scope ignore = PropagatedContext.getOrEmpty().plus(new ServerHttpRequestContext(req)).propagate()) { CompletableFuture termination = new CompletableFuture<>(); - lc.handleNormal() + lc.handleNormal(req) .onComplete((response, throwable) -> { try { onComplete(exchange, req, response.toMutableResponse(), throwable, requestTerminated); @@ -501,17 +501,17 @@ private String getDefaultMediaType(Object result) { } private final class ServletRequestLifecycle extends RequestLifecycle { - ServletRequestLifecycle(RouteExecutor routeExecutor, HttpRequest request) { - super(routeExecutor, request); + ServletRequestLifecycle(RouteExecutor routeExecutor) { + super(routeExecutor); } - ExecutionFlow> handleNormal() { - return normalFlow(); + ExecutionFlow> handleNormal(HttpRequest request) { + return normalFlow(request); } @Override - protected FileCustomizableResponseType findFile() { - return matchFile(request().getPath()).orElse(null); + protected FileCustomizableResponseType findFile(HttpRequest request) { + return matchFile(request.getPath()).orElse(null); } } }