Author: remy.maucherat(a)jboss.com
Date: 2010-06-29 06:30:20 -0400 (Tue, 29 Jun 2010)
New Revision: 1495
Modified:
trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
trunk/java/org/apache/coyote/http11/Http11Processor.java
trunk/java/org/apache/coyote/http11/filters/BufferedInputFilter.java
Log:
- Fix possible NPE.
- Don't recycle buffered filter to save memory (only used in complex SSL operations).
Modified: trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
===================================================================
--- trunk/java/org/apache/coyote/http11/Http11AprProcessor.java 2010-06-28 09:12:39 UTC
(rev 1494)
+++ trunk/java/org/apache/coyote/http11/Http11AprProcessor.java 2010-06-29 10:30:20 UTC
(rev 1495)
@@ -1202,9 +1202,9 @@
// Consume and buffer the request body, so that it does not
// interfere with the client's handshake messages
if (maxSavePostSize != 0) {
- InputFilter[] inputFilters = inputBuffer.getFilters();
- ((BufferedInputFilter)
inputFilters[Constants.BUFFERED_FILTER]).setLimit(maxSavePostSize);
-
inputBuffer.addActiveFilter(inputFilters[Constants.BUFFERED_FILTER]);
+ BufferedInputFilter buffredInputFilter = new BufferedInputFilter();
+ buffredInputFilter.setLimit(maxSavePostSize);
+ inputBuffer.addActiveFilter(buffredInputFilter);
}
try {
// Configure connection to require a certificate
@@ -1786,9 +1786,6 @@
inputBuffer.addFilter(new VoidInputFilter());
outputBuffer.addFilter(new VoidOutputFilter());
- // Create and add buffered input filter
- inputBuffer.addFilter(new BufferedInputFilter());
-
// Create and add the chunked filters.
//inputBuffer.addFilter(new GzipInputFilter());
outputBuffer.addFilter(new GzipOutputFilter());
Modified: trunk/java/org/apache/coyote/http11/Http11Processor.java
===================================================================
--- trunk/java/org/apache/coyote/http11/Http11Processor.java 2010-06-28 09:12:39 UTC (rev
1494)
+++ trunk/java/org/apache/coyote/http11/Http11Processor.java 2010-06-29 10:30:20 UTC (rev
1495)
@@ -1136,9 +1136,9 @@
// Consume and buffer the request body, so that it does not
// interfere with the client's handshake messages
if (maxSavePostSize != 0) {
- InputFilter[] inputFilters = inputBuffer.getFilters();
- ((BufferedInputFilter)
inputFilters[Constants.BUFFERED_FILTER]).setLimit(maxSavePostSize);
-
inputBuffer.addActiveFilter(inputFilters[Constants.BUFFERED_FILTER]);
+ BufferedInputFilter buffredInputFilter = new BufferedInputFilter();
+ buffredInputFilter.setLimit(maxSavePostSize);
+ inputBuffer.addActiveFilter(buffredInputFilter);
}
try {
Object sslO = sslSupport.getPeerCertificateChain(true);
@@ -1669,13 +1669,10 @@
inputBuffer.addFilter(new VoidInputFilter());
outputBuffer.addFilter(new VoidOutputFilter());
- // Create and add buffered input filter
- inputBuffer.addFilter(new BufferedInputFilter());
-
// Create and add the chunked filters.
//inputBuffer.addFilter(new GzipInputFilter());
outputBuffer.addFilter(new GzipOutputFilter());
-
+
}
Modified: trunk/java/org/apache/coyote/http11/filters/BufferedInputFilter.java
===================================================================
--- trunk/java/org/apache/coyote/http11/filters/BufferedInputFilter.java 2010-06-28
09:12:39 UTC (rev 1494)
+++ trunk/java/org/apache/coyote/http11/filters/BufferedInputFilter.java 2010-06-29
10:30:20 UTC (rev 1495)
@@ -102,10 +102,13 @@
}
public void recycle() {
- if (buffered.getBuffer().length > 65536) {
- buffered = null;
- } else {
- buffered.recycle();
+ if (buffered != null) {
+ if (buffered.getBuffer() != null
+ && buffered.getBuffer().length > 65536) {
+ buffered = null;
+ } else {
+ buffered.recycle();
+ }
}
tempRead.recycle();
hasRead = false;