From 278ce7b9be26fc417bb1e1b51fd1bfefea6f72c8 Mon Sep 17 00:00:00 2001 From: Tim Yates Date: Tue, 22 Aug 2023 11:24:30 +0100 Subject: [PATCH] Fix Error handler rebinding the body (#548) * Fix Error handler rebinding the body When we read the body for a request, and then try to re-read it for a different Body type in an error handler, we fail as the stream is already exhausted This PR caches the input-stream and re-sets it whenever the input-stream is re-required Also updated micronaut core, reactor and undertow * Revert change and document issues --- gradle/libs.versions.toml | 6 +++--- src/main/docs/guide/knownIssues.adoc | 10 ++++++++++ src/main/docs/guide/toc.yml | 1 + .../tck/jetty/tests/JettyHttpServerTestSuite.java | 1 + .../tck/tomcat/tests/TomcatHttpServerTestSuite.java | 3 ++- .../undertow/tests/UndertowHttpServerTestSuite.java | 3 ++- 6 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 src/main/docs/guide/knownIssues.adoc diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index fd9fc7089..03b1f2f8b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -micronaut = "4.0.0" +micronaut = "4.0.5" micronaut-docs = "2.0.0" micronaut-test = "4.0.0" @@ -9,13 +9,13 @@ spock = "2.3-groovy-4.0" managed-servlet-api = '6.0.0' kotlin-coroutines = '1.7.3' kotest-runner = '5.6.2' -undertow = '2.3.7.Final' +undertow = '2.3.8.Final' jetty = '11.0.15' tomcat = '10.1.11' graal-svm = "23.0.1" bcpkix = "1.70" -micronaut-reactor = "3.0.0" +micronaut-reactor = "3.0.2" micronaut-security = "4.0.3" micronaut-serde = "2.0.0" micronaut-session = "4.0.0" diff --git a/src/main/docs/guide/knownIssues.adoc b/src/main/docs/guide/knownIssues.adoc new file mode 100644 index 000000000..913573c2b --- /dev/null +++ b/src/main/docs/guide/knownIssues.adoc @@ -0,0 +1,10 @@ +There are some known issues with Servlet integration to the Micronaut Framework + +=== HttpProxyClient and Server Filters + +It is not currently possible to use the HttpProxyClient with Servlet Filters. + +=== Error handlers re-reading the request body + +Local error handlers that require the request body to be reparsed will not work in Servlet based applications. +The body is read from the request input-stream and so attempting to reparse it for the error handler will fail. diff --git a/src/main/docs/guide/toc.yml b/src/main/docs/guide/toc.yml index f034ecc3f..f709b8ed9 100644 --- a/src/main/docs/guide/toc.yml +++ b/src/main/docs/guide/toc.yml @@ -5,6 +5,7 @@ warDeployment: WAR Deployment jetty: Jetty Server tomcat: Tomcat Server undertow: Undertow Server +knownIssues: Known Issues faq: FAQ breaks: Breaking Changes repository: Repository 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 5f7feb205..49f253806 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 @@ -15,6 +15,7 @@ "io.micronaut.http.server.tck.tests.staticresources.StaticResourceTest", // Graal fails to see /assets from the TCK as a resource https://ge.micronaut.io/s/ufuhtbe5sgmxi "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 }) 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 511f69177..c2489fc18 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 @@ -11,7 +11,8 @@ @ExcludeClassNamePatterns({ "io.micronaut.http.server.tck.tests.staticresources.StaticResourceTest", // Graal fails to see /assets from the TCK as a resource https://ge.micronaut.io/s/ufuhtbe5sgmxi "io.micronaut.http.server.tck.tests.filter.ClientResponseFilterTest", // responseFilterThrowableParameter fails under Graal https://ge.micronaut.io/s/ufuhtbe5sgmxi - "io.micronaut.http.server.tck.tests.codec.JsonCodeAdditionalTypeTest", // remove once this pr is merged https://github.com/micronaut-projects/micronaut-core/pull/9419 + "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 }) 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 146f006c5..2e507c78b 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 @@ -12,8 +12,9 @@ "io.micronaut.http.server.tck.tests.RemoteAddressTest", // Undertow.getHost() reports an ipv6 address, not 127.0.0.1 "io.micronaut.http.server.tck.tests.staticresources.StaticResourceTest", // Graal fails to see /assets from the TCK as a resource https://ge.micronaut.io/s/ufuhtbe5sgmxi "io.micronaut.http.server.tck.tests.filter.ClientResponseFilterTest", // responseFilterThrowableParameter fails under Graal https://ge.micronaut.io/s/ufuhtbe5sgmxi - "io.micronaut.http.server.tck.tests.codec.JsonCodeAdditionalTypeTest", // remove once this pr is merged https://github.com/micronaut-projects/micronaut-core/pull/9419 "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 }) public class UndertowHttpServerTestSuite { }