Skip to content

Commit

Permalink
Fix Error handler rebinding the body (#548)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
timyates authored Aug 22, 2023
1 parent 70ae39e commit 278ce7b
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 5 deletions.
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
micronaut = "4.0.0"
micronaut = "4.0.5"
micronaut-docs = "2.0.0"
micronaut-test = "4.0.0"

Expand All @@ -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"
Expand Down
10 changes: 10 additions & 0 deletions src/main/docs/guide/knownIssues.adoc
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions src/main/docs/guide/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
}

0 comments on commit 278ce7b

Please sign in to comment.