Author: remy.maucherat(a)jboss.com
Date: 2009-11-28 11:11:12 -0500 (Sat, 28 Nov 2009)
New Revision: 1305
Modified:
trunk/java/org/apache/catalina/connector/Request.java
trunk/java/org/apache/catalina/connector/RequestFacade.java
trunk/java/org/apache/catalina/core/ApplicationFilterFactory.java
Log:
- get/setFilterChain should not have side effects. This fixes NPE regressions displaying
the call stack or using isAsyncSupported.
Modified: trunk/java/org/apache/catalina/connector/Request.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Request.java 2009-11-28 00:17:25 UTC (rev
1304)
+++ trunk/java/org/apache/catalina/connector/Request.java 2009-11-28 16:11:12 UTC (rev
1305)
@@ -653,7 +653,7 @@
* Get filter chain associated with the request.
*/
public ApplicationFilterChain getFilterChain() {
- if (currentFilterChain >= 0) {
+ if (currentFilterChain >= 0 && currentFilterChain <
filterChains.size()) {
return filterChains.get(currentFilterChain);
} else {
return null;
@@ -667,11 +667,10 @@
* @param filterChain new filter chain
*/
public void setFilterChain(ApplicationFilterChain filterChain) {
- if (currentFilterChain + 1 < filterChains.size()) {
- filterChains.set(++currentFilterChain, filterChain);
+ if (currentFilterChain >= 0 && currentFilterChain <
filterChains.size()) {
+ filterChains.set(currentFilterChain, filterChain);
} else {
filterChains.add(filterChain);
- currentFilterChain++;
}
}
@@ -681,6 +680,16 @@
*
* @param filterChain new filter chain
*/
+ public void nextFilterChain() {
+ currentFilterChain++;
+ }
+
+
+ /**
+ * Set filter chain associated with the request.
+ *
+ * @param filterChain new filter chain
+ */
public void releaseFilterChain() {
currentFilterChain--;
}
Modified: trunk/java/org/apache/catalina/connector/RequestFacade.java
===================================================================
--- trunk/java/org/apache/catalina/connector/RequestFacade.java 2009-11-28 00:17:25 UTC
(rev 1304)
+++ trunk/java/org/apache/catalina/connector/RequestFacade.java 2009-11-28 16:11:12 UTC
(rev 1305)
@@ -1039,6 +1039,18 @@
/**
+ * Next filter chain.
+ */
+ public void nextFilterChain() {
+ if (request == null) {
+ throw new IllegalStateException(
+ sm.getString("requestFacade.nullRequest"));
+ }
+ request.nextFilterChain();
+ }
+
+
+ /**
* Release the current filter chain.
*/
public void releaseFilterChain() {
Modified: trunk/java/org/apache/catalina/core/ApplicationFilterFactory.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationFilterFactory.java 2009-11-28 00:17:25
UTC (rev 1304)
+++ trunk/java/org/apache/catalina/core/ApplicationFilterFactory.java 2009-11-28 16:11:12
UTC (rev 1305)
@@ -171,6 +171,7 @@
filterChain = new ApplicationFilterChain();
} else {
// Add this filter chain to the request facade
+ requestFacade.nextFilterChain();
if (Globals.IS_SECURITY_ENABLED) {
filterChain = new ApplicationFilterChain();
requestFacade.setFilterChain(filterChain);
Show replies by date