Previously, the error page filter used sendError to set the response
status when handling an exception and before forwarding the request
to the error controller. Following the fix for gh-11814, this meant
that the error controller was unable to write its response and the
containers default error page was returned instead.
This commit updates the error page filter to use setStatus rather than
sendError. This ensures that the response has the correct status code
while allowing the error controller to write its body. Tests have
been added to the Tomcat deployment test suite to verify that the
error page filter behaves as intended when dealing with a sent error
and an exception for requests accepting HTML, JSON, or anything.
Closes gh-12787
Previously, ErrorPageFilter's ErrorResponseWrapper would delaying
sending an error back to the client. In cases where the response's
Writer or OutputStream was accessed and flushed or closed, this could
lead to the wrong response status being sent.
This commit updates ErrorResponseWrapper so that it will send any
capture error to the client before returning the response's Writer or
OutputStream. This ensures that closing the Writer or OutputStream
does not cause the response to be committed with the default response
status rather than the previously captured error status.
Such responses will now include the correct status, but will not be
forwarded to the error controller. Such forwarding is not possible
due to the response already having been committed.
Closes gh-11814
Previously, when a project contained multiple `@ServletComponentScan`
annotated classes in classpath, and at least one annotation don't
explicitly specify `basePackages` and `basePackageClass` attribute,
the application could fail to start with an
UnsupportedOperationException. The failure occurred due to the
creating of an unmodifiable set when no base packages are configured
and a subsequent attempt to add base packages to that sit.
This commit fixes the issue by removing the use of an unmodifiable set
when `@ServletComponentScan` with no base packages in processed before
any other `@ServletComponentScan` annotations.
See gh-12715
Update `Restarter` to be much more defensive when attempting to clear
caches. We now use `clearCache()` methods whenever possible, and only
fall back to field access when absolutely necessary. In addition field
access now ignore any exceptions.
Fixes gh-12719
IntelliJ can shorten the classpath to a single classpath.jar in order to
circumvent errors originating from a too long classpath. This breaks the
filtering inside ModifiedClassPathRunner as the classpath contains only a
single jar to match against. This can be fixed by applying a similar
mechanism already provided for Surefire manifest-only booter JARs, which
extracts the real classpath from the JAR's Manifest file.
See gh-12535
Refine `BasicErrorController` mappings so that only JSON and XML get
structured responses. A simple string response is returned for all
other media types.
Fixes gh-12513