This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new 2654e1dae4 Look up response wrappers to suspend
2654e1dae4 is described below
commit 2654e1dae4566feeed05116bd339a0366f19e72e
Author: remm <[email protected]>
AuthorDate: Mon Mar 4 10:17:39 2024 +0100
Look up response wrappers to suspend
BZ 68634 shows the implications and behavior difference between suspend
and close for response generation.
A flag could be added to make this optional if needed. I will delay
backporting this to other branches since this is a behavior change.
---
.../apache/catalina/core/ApplicationDispatcher.java | 20 +++++++++++++++-----
.../org/apache/catalina/core/LocalStrings.properties | 1 +
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/java/org/apache/catalina/core/ApplicationDispatcher.java
b/java/org/apache/catalina/core/ApplicationDispatcher.java
index 0707cf8eb3..d7abfe6ba4 100644
--- a/java/org/apache/catalina/core/ApplicationDispatcher.java
+++ b/java/org/apache/catalina/core/ApplicationDispatcher.java
@@ -295,16 +295,26 @@ final class ApplicationDispatcher implements
AsyncDispatcher, RequestDispatcher
wrapper.getLogger().trace(" Disabling the response for further
output");
}
+ boolean finished = false;
if (response instanceof ResponseFacade) {
+ finished = true;
((ResponseFacade) response).finish();
- } else {
+ } else if (response instanceof ServletResponseWrapper) {
+ ServletResponse baseResponse = response;
+ do {
+ baseResponse = ((ServletResponseWrapper)
baseResponse).getResponse();
+ } while (baseResponse instanceof ServletResponseWrapper);
+ if (baseResponse instanceof ResponseFacade) {
+ finished = true;
+ ((ResponseFacade) baseResponse).finish();
+ }
+ }
+ if (!finished) {
// Servlet SRV.6.2.2. The Request/Response may have been wrapped
// and may no longer be instance of RequestFacade
- if (wrapper.getLogger().isTraceEnabled()) {
- wrapper.getLogger()
- .trace(" The Response is vehiculed using a wrapper: "
+ response.getClass().getName());
+ if (wrapper.getLogger().isDebugEnabled()) {
+
wrapper.getLogger().debug(sm.getString("applicationDispatcher.customResponse",
response.getClass()));
}
-
// Close anyway
try {
PrintWriter writer = response.getWriter();
diff --git a/java/org/apache/catalina/core/LocalStrings.properties
b/java/org/apache/catalina/core/LocalStrings.properties
index a335cdcd34..6c91188d22 100644
--- a/java/org/apache/catalina/core/LocalStrings.properties
+++ b/java/org/apache/catalina/core/LocalStrings.properties
@@ -42,6 +42,7 @@ applicationContext.setSessionTracking.iae.ssl=The session
tracking modes request
applicationContext.setSessionTracking.ise=The session tracking modes for
context [{0}] cannot be set whilst the context is running
applicationDispatcher.allocateException=Allocate exception for servlet [{0}]
+applicationDispatcher.customResponse=The response class [{0}] could not be
unwraped to the Catalina response class and will be closed immediately after
the forward
applicationDispatcher.deallocateException=Deallocate exception for servlet
[{0}]
applicationDispatcher.forward.ise=Cannot forward after response has been
committed
applicationDispatcher.isUnavailable=Servlet [{0}] is currently unavailable
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]