Skip to content

Commit 52ba355

Browse files
committed
Minor fixes from code review
Most significant is the rework of the wrapper unload.
1 parent fd019fd commit 52ba355

18 files changed

Lines changed: 59 additions & 47 deletions

java/org/apache/catalina/core/ApplicationDispatcher.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,6 @@ public void dispatch(ServletRequest request, ServletResponse response) throws Se
450450
/**
451451
* Ask the resource represented by this RequestDispatcher to process the associated request, and create (or append
452452
* to) the associated response.
453-
* <p>
454-
* <strong>IMPLEMENTATION NOTE</strong>: This implementation assumes that no filters are applied to a forwarded or
455-
* included resource, because they were already done for the original request.
456453
*
457454
* @param request The servlet request we are processing
458455
* @param response The servlet response we are creating

java/org/apache/catalina/core/ApplicationHttpRequest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
* Wrapper around a <code>jakarta.servlet.http.HttpServletRequest</code> that transforms an application request object
5555
* (which might be the original one passed to a servlet, or might be based on the 2.3
5656
* <code>jakarta.servlet.http.HttpServletRequestWrapper</code> class) back into an internal
57-
* <code>org.apache.catalina.HttpRequest</code>.
57+
* <code>org.apache.catalina.connector.Request</code>.
5858
* <p>
5959
* <strong>WARNING</strong>: Due to Java's lack of support for multiple inheritance, all of the logic in
6060
* <code>ApplicationRequest</code> is duplicated in <code>ApplicationHttpRequest</code>. Make sure that you keep these
@@ -621,7 +621,8 @@ public boolean isRequestedSessionIdValid() {
621621
// -------------------------------------------------------- Package Methods
622622

623623
/**
624-
* Recycle this request
624+
* Recycle this request. Since there is no object reuse, this only ends
625+
* the session access.
625626
*/
626627
public void recycle() {
627628
if (session != null) {

java/org/apache/catalina/core/ApplicationHttpResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* Wrapper around a <code>jakarta.servlet.http.HttpServletResponse</code> that transforms an application response object
2929
* (which might be the original one passed to a servlet, or might be based on the 2.3
3030
* <code>jakarta.servlet.http.HttpServletResponseWrapper</code> class) back into an internal
31-
* <code>org.apache.catalina.HttpResponse</code>.
31+
* <code>org.apache.catalina.connector.Response</code>.
3232
* <p>
3333
* <strong>WARNING</strong>: Due to Java's lack of support for multiple inheritance, all of the logic in
3434
* <code>ApplicationResponse</code> is duplicated in <code>ApplicationHttpResponse</code>. Make sure that you keep these

java/org/apache/catalina/core/ApplicationRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* Wrapper around a <code>jakarta.servlet.ServletRequest</code> that transforms an application request object (which
3434
* might be the original one passed to a servlet, or might be based on the 2.3
3535
* <code>jakarta.servlet.ServletRequestWrapper</code> class) back into an internal
36-
* <code>org.apache.catalina.Request</code>.
36+
* <code>org.apache.catalina.connector.Request</code>.
3737
* <p>
3838
* <strong>WARNING</strong>: Due to Java's lack of support for multiple inheritance, all of the logic in
3939
* <code>ApplicationRequest</code> is duplicated in <code>ApplicationHttpRequest</code>. Make sure that you keep these

java/org/apache/catalina/core/ApplicationResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* Wrapper around a <code>jakarta.servlet.ServletResponse</code> that transforms an application response object (which
2727
* might be the original one passed to a servlet, or might be based on the 2.3
2828
* <code>jakarta.servlet.ServletResponseWrapper</code> class) back into an internal
29-
* <code>org.apache.catalina.Response</code>.
29+
* <code>org.apache.catalina.connector.Response</code>.
3030
* <p>
3131
* <strong>WARNING</strong>: Due to Java's lack of support for multiple inheritance, all of the logic in
3232
* <code>ApplicationResponse</code> is duplicated in <code>ApplicationHttpResponse</code>. Make sure that you keep these

java/org/apache/catalina/core/ApplicationServletRegistration.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ public Set<String> addMapping(String... urlPatterns) {
196196
*/
197197
overrides.add(decodedUrlPatterns[i]);
198198
} else {
199+
// The conflicts list the original URL patterns passed
199200
conflicts.add(urlPatterns[i]);
200201
}
201202
}

java/org/apache/catalina/core/AsyncContextImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ private void logDebug(String method) {
644644

645645
private void check() {
646646
Request request = this.request;
647-
if (hasBeenRecycled.get()) {
647+
if (hasBeenRecycled.get() || request == null) {
648648
// AsyncContext has been recycled and should not be being used
649649
throw new IllegalStateException(sm.getString("asyncContextImpl.requestEnded"));
650650
}

java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public void lifecycleEvent(LifecycleEvent event) {
238238

239239
// Set the default URL caching policy to not to cache
240240
if (urlCacheProtection) {
241-
URLConnection.setDefaultUseCaches("JAR", false);
241+
URLConnection.setDefaultUseCaches("jar", false);
242242
}
243243

244244
/*

java/org/apache/catalina/core/NamingContextListener.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,14 @@
3737
import javax.naming.Reference;
3838
import javax.naming.StringRefAddr;
3939

40+
import org.apache.catalina.Container;
4041
import org.apache.catalina.Context;
41-
import org.apache.catalina.Engine;
4242
import org.apache.catalina.Host;
4343
import org.apache.catalina.Lifecycle;
4444
import org.apache.catalina.LifecycleEvent;
4545
import org.apache.catalina.LifecycleListener;
4646
import org.apache.catalina.Server;
47+
import org.apache.catalina.Service;
4748
import org.apache.catalina.deploy.NamingResourcesImpl;
4849
import org.apache.juli.logging.Log;
4950
import org.apache.juli.logging.LogFactory;
@@ -1083,11 +1084,13 @@ public void addResourceLink(ContextResourceLink resourceLink) {
10831084

10841085
private javax.naming.Context getGlobalNamingContext() {
10851086
if (container instanceof Context) {
1086-
Engine e = (Engine) ((Context) container).getParent().getParent();
1087-
Server s = e.getService().getServer();
1088-
// When the Service is an embedded Service, there is no Server
1089-
if (s != null) {
1090-
return s.getGlobalNamingContext();
1087+
Service service = Container.getService((Context) container);
1088+
if (service != null) {
1089+
Server s = service.getServer();
1090+
// When the Service is an embedded Service, there is no Server
1091+
if (s != null) {
1092+
return s.getGlobalNamingContext();
1093+
}
10911094
}
10921095
}
10931096
return null;

java/org/apache/catalina/core/StandardEngineValve.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ public void invoke(Request request, Response response) throws IOException, Servl
5656
// Select the Host to be used for this Request
5757
Host host = request.getHost();
5858
if (host == null) {
59-
// HTTP 0.9 or HTTP 1.0 request without a host when no default host
60-
// is defined.
59+
// No Host found for this request (unknown server name or no default host defined)
6160
// Don't overwrite an existing error
6261
if (!response.isError()) {
6362
response.sendError(404);

0 commit comments

Comments
 (0)