You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2011/10/22 21:21:10 UTC
svn commit: r1187753 [1/4] - in /tomcat/trunk/java/org/apache:
catalina/connector/ tomcat/util/buf/ tomcat/util/http/
Author: markt
Date: Sat Oct 22 19:21:08 2011
New Revision: 1187753
URL: http://svn.apache.org/viewvc?rev=1187753&view=rev
Log:
Clean-up. No functional change.
Modified:
tomcat/trunk/java/org/apache/catalina/connector/ClientAbortException.java
tomcat/trunk/java/org/apache/catalina/connector/CometEventImpl.java
tomcat/trunk/java/org/apache/catalina/connector/Connector.java
tomcat/trunk/java/org/apache/catalina/connector/Constants.java
tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
tomcat/trunk/java/org/apache/catalina/connector/CoyoteInputStream.java
tomcat/trunk/java/org/apache/catalina/connector/CoyoteOutputStream.java
tomcat/trunk/java/org/apache/catalina/connector/CoyotePrincipal.java
tomcat/trunk/java/org/apache/catalina/connector/CoyoteReader.java
tomcat/trunk/java/org/apache/catalina/connector/CoyoteWriter.java
tomcat/trunk/java/org/apache/catalina/connector/InputBuffer.java
tomcat/trunk/java/org/apache/catalina/connector/MapperListener.java
tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java
tomcat/trunk/java/org/apache/catalina/connector/Request.java
tomcat/trunk/java/org/apache/catalina/connector/RequestFacade.java
tomcat/trunk/java/org/apache/catalina/connector/Response.java
tomcat/trunk/java/org/apache/catalina/connector/ResponseFacade.java
tomcat/trunk/java/org/apache/tomcat/util/buf/Ascii.java
tomcat/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java
tomcat/trunk/java/org/apache/tomcat/util/buf/ByteChunk.java
tomcat/trunk/java/org/apache/tomcat/util/buf/C2BConverter.java
tomcat/trunk/java/org/apache/tomcat/util/buf/CharChunk.java
tomcat/trunk/java/org/apache/tomcat/util/buf/Constants.java
tomcat/trunk/java/org/apache/tomcat/util/buf/HexUtils.java
tomcat/trunk/java/org/apache/tomcat/util/buf/MessageBytes.java
tomcat/trunk/java/org/apache/tomcat/util/buf/StringCache.java
tomcat/trunk/java/org/apache/tomcat/util/buf/UDecoder.java
tomcat/trunk/java/org/apache/tomcat/util/buf/UEncoder.java
tomcat/trunk/java/org/apache/tomcat/util/http/ContentType.java
tomcat/trunk/java/org/apache/tomcat/util/http/CookieSupport.java
tomcat/trunk/java/org/apache/tomcat/util/http/Cookies.java
tomcat/trunk/java/org/apache/tomcat/util/http/FastHttpDateFormat.java
tomcat/trunk/java/org/apache/tomcat/util/http/HttpMessages.java
tomcat/trunk/java/org/apache/tomcat/util/http/MimeHeaders.java
tomcat/trunk/java/org/apache/tomcat/util/http/Parameters.java
tomcat/trunk/java/org/apache/tomcat/util/http/ServerCookie.java
Modified: tomcat/trunk/java/org/apache/catalina/connector/ClientAbortException.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/ClientAbortException.java?rev=1187753&r1=1187752&r2=1187753&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/ClientAbortException.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/ClientAbortException.java Sat Oct 22 19:21:08 2011
@@ -5,17 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package org.apache.catalina.connector;
import java.io.IOException;
@@ -32,7 +30,7 @@ public final class ClientAbortException
private static final long serialVersionUID = 1L;
-
+
//------------------------------------------------------------ Constructors
/**
@@ -119,12 +117,12 @@ public final class ClientAbortException
*/
@Override
public Throwable getCause() {
-
+
return (throwable);
-
+
}
-
+
/**
* Return a formatted string that describes this exception.
*/
Modified: tomcat/trunk/java/org/apache/catalina/connector/CometEventImpl.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/CometEventImpl.java?rev=1187753&r1=1187752&r2=1187753&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/CometEventImpl.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/CometEventImpl.java Sat Oct 22 19:21:08 2011
@@ -5,17 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package org.apache.catalina.connector;
import java.io.IOException;
@@ -45,7 +43,7 @@ public class CometEventImpl implements C
// ----------------------------------------------------- Instance Variables
-
+
/**
* Associated request.
*/
@@ -57,18 +55,18 @@ public class CometEventImpl implements C
*/
protected Response response = null;
-
+
/**
* Event type.
*/
protected EventType eventType = EventType.BEGIN;
-
+
/**
* Event sub type.
*/
protected EventSubType eventSubType = null;
-
+
// --------------------------------------------------------- Public Methods
@@ -83,11 +81,11 @@ public class CometEventImpl implements C
public void setEventType(EventType eventType) {
this.eventType = eventType;
}
-
+
public void setEventSubType(EventSubType eventSubType) {
this.eventSubType = eventSubType;
}
-
+
@Override
public void close() throws IOException {
if (request == null) {
@@ -125,12 +123,14 @@ public class CometEventImpl implements C
UnsupportedOperationException {
if (request.getAttribute("org.apache.tomcat.comet.timeout.support") == Boolean.TRUE) {
request.setAttribute("org.apache.tomcat.comet.timeout", Integer.valueOf(timeout));
- if (request.isComet()) request.setCometTimeout(timeout);
+ if (request.isComet()) {
+ request.setCometTimeout(timeout);
+ }
} else {
throw new UnsupportedOperationException();
}
}
-
+
@Override
public String toString() {
StringBuilder buf = new StringBuilder();
Modified: tomcat/trunk/java/org/apache/catalina/connector/Connector.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/Connector.java?rev=1187753&r1=1187752&r2=1187753&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/Connector.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/Connector.java Sat Oct 22 19:21:08 2011
@@ -14,8 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package org.apache.catalina.connector;
import java.util.Arrays;
@@ -343,7 +341,7 @@ public class Connector extends Lifecycle
}
-
+
/**
* Return the default timeout for async requests in ms.
*/
@@ -366,7 +364,7 @@ public class Connector extends Lifecycle
}
-
+
/**
* Return the "enable DNS lookups" flag.
*/
@@ -469,11 +467,13 @@ public class Connector extends Lifecycle
HashSet<String> methodSet = new HashSet<String>();
- if( null != methods )
+ if( null != methods ) {
methodSet.addAll(Arrays.asList(methods.split("\\s*,\\s*")));
+ }
- if( methodSet.contains("TRACE") )
+ if( methodSet.contains("TRACE") ) {
throw new IllegalArgumentException(sm.getString("coyoteConnector.parseBodyMethodNoTrace"));
+ }
this.parseBodyMethods = methods;
this.parseBodyMethodsSet = methodSet;
@@ -528,7 +528,7 @@ public class Connector extends Lifecycle
return getProtocolHandlerClassName();
}
-
+
/**
* Set the Coyote protocol which will be used by the connector.
@@ -848,7 +848,7 @@ public class Connector extends Lifecycle
protected String createObjectNameKeyProperties(String type) {
-
+
Object addressObj = getProperty("address");
StringBuilder sb = new StringBuilder("type=");
@@ -896,14 +896,15 @@ public class Connector extends Lifecycle
protected void initInternal() throws LifecycleException {
super.initInternal();
-
+
// Initialize adapter
adapter = new CoyoteAdapter(this);
protocolHandler.setAdapter(adapter);
// Make sure parseBodyMethodsSet has a default
- if( null == parseBodyMethodsSet )
+ if( null == parseBodyMethodsSet ) {
setParseBodyMethods(getParseBodyMethods());
+ }
try {
protocolHandler.init();
@@ -976,7 +977,7 @@ public class Connector extends Lifecycle
@Override
protected void destroyInternal() throws LifecycleException {
mapperListener.destroy();
-
+
try {
protocolHandler.destroy();
} catch (Exception e) {
@@ -988,7 +989,7 @@ public class Connector extends Lifecycle
if (getService() != null) {
getService().removeConnector(this);
}
-
+
super.destroyInternal();
}
Modified: tomcat/trunk/java/org/apache/catalina/connector/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/Constants.java?rev=1187753&r1=1187752&r2=1187753&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/Constants.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/Constants.java Sat Oct 22 19:21:08 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Modified: tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java?rev=1187753&r1=1187752&r2=1187753&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java Sat Oct 22 19:21:08 2011
@@ -14,8 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package org.apache.catalina.connector;
import java.io.IOException;
Modified: tomcat/trunk/java/org/apache/catalina/connector/CoyoteInputStream.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/CoyoteInputStream.java?rev=1187753&r1=1187752&r2=1187753&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/CoyoteInputStream.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/CoyoteInputStream.java Sat Oct 22 19:21:08 2011
@@ -5,17 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
-
-
+ */
package org.apache.catalina.connector;
import java.io.IOException;
@@ -29,7 +27,7 @@ import org.apache.catalina.security.Secu
/**
* This class handles reading bytes.
- *
+ *
* @author Remy Maucherat
* @author Jean-Francois Arcand
*/
@@ -80,11 +78,11 @@ public class CoyoteInputStream
@Override
public int read()
- throws IOException {
+ throws IOException {
if (SecurityUtil.isPackageProtectionEnabled()){
-
+
try{
- Integer result =
+ Integer result =
AccessController.doPrivileged(
new PrivilegedExceptionAction<Integer>(){
@@ -111,10 +109,10 @@ public class CoyoteInputStream
@Override
public int available() throws IOException {
-
+
if (SecurityUtil.isPackageProtectionEnabled()){
try{
- Integer result =
+ Integer result =
AccessController.doPrivileged(
new PrivilegedExceptionAction<Integer>(){
@@ -136,21 +134,21 @@ public class CoyoteInputStream
}
} else {
return ib.available();
- }
+ }
}
@Override
public int read(final byte[] b) throws IOException {
-
+
if (SecurityUtil.isPackageProtectionEnabled()){
try{
- Integer result =
+ Integer result =
AccessController.doPrivileged(
new PrivilegedExceptionAction<Integer>(){
@Override
public Integer run() throws IOException{
- Integer integer =
+ Integer integer =
Integer.valueOf(ib.read(b, 0, b.length));
return integer;
}
@@ -167,23 +165,23 @@ public class CoyoteInputStream
}
} else {
return ib.read(b, 0, b.length);
- }
+ }
}
@Override
public int read(final byte[] b, final int off, final int len)
throws IOException {
-
+
if (SecurityUtil.isPackageProtectionEnabled()){
try{
- Integer result =
+ Integer result =
AccessController.doPrivileged(
new PrivilegedExceptionAction<Integer>(){
@Override
public Integer run() throws IOException{
- Integer integer =
+ Integer integer =
Integer.valueOf(ib.read(b, off, len));
return integer;
}
@@ -200,7 +198,7 @@ public class CoyoteInputStream
}
} else {
return ib.read(b, off, len);
- }
+ }
}
@@ -210,14 +208,14 @@ public class CoyoteInputStream
}
- /**
+ /**
* Close the stream
* Since we re-cycle, we can't allow the call to super.close()
* which would permanently disable us.
*/
@Override
public void close() throws IOException {
-
+
if (SecurityUtil.isPackageProtectionEnabled()){
try{
AccessController.doPrivileged(
Modified: tomcat/trunk/java/org/apache/catalina/connector/CoyoteOutputStream.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/CoyoteOutputStream.java?rev=1187753&r1=1187752&r2=1187753&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/CoyoteOutputStream.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/CoyoteOutputStream.java Sat Oct 22 19:21:08 2011
@@ -5,17 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
-
-
+ */
package org.apache.catalina.connector;
import java.io.IOException;
@@ -24,11 +22,11 @@ import javax.servlet.ServletOutputStream
/**
* Coyote implementation of the servlet output stream.
- *
+ *
* @author Costin Manolache
* @author Remy Maucherat
*/
-public class CoyoteOutputStream
+public class CoyoteOutputStream
extends ServletOutputStream {
Modified: tomcat/trunk/java/org/apache/catalina/connector/CoyotePrincipal.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/CoyotePrincipal.java?rev=1187753&r1=1187752&r2=1187753&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/CoyotePrincipal.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/CoyotePrincipal.java Sat Oct 22 19:21:08 2011
@@ -5,17 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package org.apache.catalina.connector;
import java.io.Serializable;
Modified: tomcat/trunk/java/org/apache/catalina/connector/CoyoteReader.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/CoyoteReader.java?rev=1187753&r1=1187752&r2=1187753&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/CoyoteReader.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/CoyoteReader.java Sat Oct 22 19:21:08 2011
@@ -5,17 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
-
-
+ */
package org.apache.catalina.connector;
import java.io.BufferedReader;
@@ -24,7 +22,7 @@ import java.io.IOException;
/**
* Coyote implementation of the buffered reader.
- *
+ *
* @author Remy Maucherat
*/
public class CoyoteReader
Modified: tomcat/trunk/java/org/apache/catalina/connector/CoyoteWriter.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/CoyoteWriter.java?rev=1187753&r1=1187752&r2=1187753&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/CoyoteWriter.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/CoyoteWriter.java Sat Oct 22 19:21:08 2011
@@ -5,17 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
-
-
+ */
package org.apache.catalina.connector;
import java.io.IOException;
@@ -23,7 +21,7 @@ import java.io.PrintWriter;
/**
* Coyote implementation of the servlet writer.
- *
+ *
* @author Remy Maucherat
*/
public class CoyoteWriter
@@ -92,8 +90,9 @@ public class CoyoteWriter
@Override
public void flush() {
- if (error)
+ if (error) {
return;
+ }
try {
ob.flush();
@@ -129,8 +128,9 @@ public class CoyoteWriter
@Override
public void write(int c) {
- if (error)
+ if (error) {
return;
+ }
try {
ob.write(c);
@@ -144,8 +144,9 @@ public class CoyoteWriter
@Override
public void write(char buf[], int off, int len) {
- if (error)
+ if (error) {
return;
+ }
try {
ob.write(buf, off, len);
@@ -165,8 +166,9 @@ public class CoyoteWriter
@Override
public void write(String s, int off, int len) {
- if (error)
+ if (error) {
return;
+ }
try {
ob.write(s, off, len);
Modified: tomcat/trunk/java/org/apache/catalina/connector/InputBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/InputBuffer.java?rev=1187753&r1=1187752&r2=1187753&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/InputBuffer.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/InputBuffer.java Sat Oct 22 19:21:08 2011
@@ -5,16 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
-
+ */
package org.apache.catalina.connector;
import java.io.IOException;
@@ -35,7 +34,7 @@ import org.apache.tomcat.util.res.String
/**
* The buffer used by Tomcat request. This is a derivative of the Tomcat 3.3
- * OutputBuffer, adapted to handle input instead of output. This allows
+ * OutputBuffer, adapted to handle input instead of output. This allows
* complete recycling of the facade objects (the ServletInputStream and the
* BufferedReader).
*
@@ -55,7 +54,7 @@ public class InputBuffer extends Reader
// -------------------------------------------------------------- Constants
- public static final String DEFAULT_ENCODING =
+ public static final String DEFAULT_ENCODING =
org.apache.coyote.Constants.DEFAULT_CHARACTER_ENCODING;
public static final int DEFAULT_BUFFER_SIZE = 8*1024;
@@ -71,7 +70,7 @@ public class InputBuffer extends Reader
/**
* The byte buffer.
*/
- private ByteChunk bb;
+ private final ByteChunk bb;
/**
@@ -150,7 +149,7 @@ public class InputBuffer extends Reader
/**
* Alternate constructor which allows specifying the initial buffer size.
- *
+ *
* @param size Buffer size to use
*/
public InputBuffer(int size) {
@@ -173,7 +172,7 @@ public class InputBuffer extends Reader
/**
* Associated Coyote request.
- *
+ *
* @param coyoteRequest Associated Coyote request
*/
public void setRequest(Request coyoteRequest) {
@@ -183,7 +182,7 @@ public class InputBuffer extends Reader
/**
* Get associated Coyote request.
- *
+ *
* @return the associated Coyote request
*/
public Request getRequest() {
@@ -198,9 +197,9 @@ public class InputBuffer extends Reader
* Recycle the output buffer.
*/
public void recycle() {
-
+
state = INITIAL_STATE;
-
+
// If usage of mark made the buffer too big, reallocate it
if (cb.getChars().length > size) {
cb = new CharChunk(size);
@@ -212,16 +211,16 @@ public class InputBuffer extends Reader
cb.recycle();
}
markPos = -1;
- bb.recycle();
+ bb.recycle();
closed = false;
-
+
if (conv != null) {
conv.recycle();
}
-
+
gotEnc = false;
enc = null;
-
+
}
@@ -231,11 +230,11 @@ public class InputBuffer extends Reader
public void clearEncoders() {
encoders.clear();
}
-
-
+
+
/**
* Close the input buffer.
- *
+ *
* @throws IOException An underlying IOException occurred
*/
@Override
@@ -263,26 +262,29 @@ public class InputBuffer extends Reader
// ------------------------------------------------- Bytes Handling Methods
- /**
+ /**
* Reads new bytes in the byte chunk.
- *
+ *
* @param cbuf Byte buffer to be written to the response
* @param off Offset
* @param len Length
- *
+ *
* @throws IOException An underlying IOException occurred
*/
@Override
public int realReadBytes(byte cbuf[], int off, int len)
throws IOException {
- if (closed)
+ if (closed) {
return -1;
- if (coyoteRequest == null)
+ }
+ if (coyoteRequest == null) {
return -1;
+ }
- if(state == INITIAL_STATE)
+ if(state == INITIAL_STATE) {
state = BYTE_STATE;
+ }
int result = coyoteRequest.doRead(bb);
@@ -294,8 +296,9 @@ public class InputBuffer extends Reader
public int readByte()
throws IOException {
- if (closed)
+ if (closed) {
throw new IOException(sm.getString("inputBuffer.streamClosed"));
+ }
return bb.substract();
}
@@ -304,8 +307,9 @@ public class InputBuffer extends Reader
public int read(byte[] b, int off, int len)
throws IOException {
- if (closed)
+ if (closed) {
throw new IOException(sm.getString("inputBuffer.streamClosed"));
+ }
return bb.substract(b, off, len);
}
@@ -321,7 +325,7 @@ public class InputBuffer extends Reader
* mark is lost.
*/
@Override
- public void realWriteChars(char c[], int off, int len)
+ public void realWriteChars(char c[], int off, int len)
throws IOException {
markPos = -1;
cb.setOffset(0);
@@ -338,8 +342,9 @@ public class InputBuffer extends Reader
public int realReadChars(char cbuf[], int off, int len)
throws IOException {
- if (!gotEnc)
+ if (!gotEnc) {
setConverter();
+ }
if (bb.getLength() <= 0) {
int nRead = realReadBytes(bb.getBytes(), 0, bb.getBytes().length);
@@ -353,8 +358,9 @@ public class InputBuffer extends Reader
cb.setEnd(0);
}
int limit = bb.getLength()+cb.getStart();
- if ( cb.getLimit() < limit )
+ if ( cb.getLimit() < limit ) {
cb.setLimit(limit);
+ }
state = CHAR_STATE;
conv.convert(bb, cb, bb.getLength());
bb.setOffset(bb.getEnd());
@@ -368,8 +374,9 @@ public class InputBuffer extends Reader
public int read()
throws IOException {
- if (closed)
+ if (closed) {
throw new IOException(sm.getString("inputBuffer.streamClosed"));
+ }
return cb.substract();
}
@@ -379,8 +386,9 @@ public class InputBuffer extends Reader
public int read(char[] cbuf)
throws IOException {
- if (closed)
+ if (closed) {
throw new IOException(sm.getString("inputBuffer.streamClosed"));
+ }
return read(cbuf, 0, cbuf.length);
}
@@ -390,8 +398,9 @@ public class InputBuffer extends Reader
public int read(char[] cbuf, int off, int len)
throws IOException {
- if (closed)
+ if (closed) {
throw new IOException(sm.getString("inputBuffer.streamClosed"));
+ }
return cb.substract(cbuf, off, len);
}
@@ -402,8 +411,9 @@ public class InputBuffer extends Reader
throws IOException {
- if (closed)
+ if (closed) {
throw new IOException(sm.getString("inputBuffer.streamClosed"));
+ }
if (n < 0) {
throw new IllegalArgumentException();
@@ -424,8 +434,9 @@ public class InputBuffer extends Reader
toRead = (int) (n - nRead);
}
int nb = realReadChars(cb.getChars(), 0, toRead);
- if (nb < 0)
+ if (nb < 0) {
break;
+ }
}
}
@@ -438,8 +449,9 @@ public class InputBuffer extends Reader
public boolean ready()
throws IOException {
- if (closed)
+ if (closed) {
throw new IOException(sm.getString("inputBuffer.streamClosed"));
+ }
return (available() > 0);
}
@@ -455,16 +467,17 @@ public class InputBuffer extends Reader
public void mark(int readAheadLimit)
throws IOException {
- if (closed)
+ if (closed) {
throw new IOException(sm.getString("inputBuffer.streamClosed"));
+ }
if (cb.getLength() <= 0) {
cb.setOffset(0);
cb.setEnd(0);
} else {
- if ((cb.getBuffer().length > (2 * size))
+ if ((cb.getBuffer().length > (2 * size))
&& (cb.getLength()) < (cb.getStart())) {
- System.arraycopy(cb.getBuffer(), cb.getStart(),
+ System.arraycopy(cb.getBuffer(), cb.getStart(),
cb.getBuffer(), 0, cb.getLength());
cb.setEnd(cb.getLength());
cb.setOffset(0);
@@ -479,8 +492,9 @@ public class InputBuffer extends Reader
public void reset()
throws IOException {
- if (closed)
+ if (closed) {
throw new IOException(sm.getString("inputBuffer.streamClosed"));
+ }
if (state == CHAR_STATE) {
if (markPos < 0) {
@@ -496,11 +510,12 @@ public class InputBuffer extends Reader
}
- public void checkConverter()
+ public void checkConverter()
throws IOException {
- if (!gotEnc)
+ if (!gotEnc) {
setConverter();
+ }
}
@@ -508,12 +523,14 @@ public class InputBuffer extends Reader
protected void setConverter()
throws IOException {
- if (coyoteRequest != null)
+ if (coyoteRequest != null) {
enc = coyoteRequest.getCharacterEncoding();
+ }
gotEnc = true;
- if (enc == null)
+ if (enc == null) {
enc = DEFAULT_ENCODING;
+ }
conv = encoders.get(enc);
if (conv == null) {
if (SecurityUtil.isPackageProtectionEnabled()){
@@ -527,11 +544,12 @@ public class InputBuffer extends Reader
}
}
- );
+ );
}catch(PrivilegedActionException ex){
Exception e = ex.getException();
- if (e instanceof IOException)
- throw (IOException)e;
+ if (e instanceof IOException) {
+ throw (IOException)e;
+ }
}
} else {
conv = new B2CConverter(enc);
Modified: tomcat/trunk/java/org/apache/catalina/connector/MapperListener.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/MapperListener.java?rev=1187753&r1=1187752&r2=1187753&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/MapperListener.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/MapperListener.java Sat Oct 22 19:21:08 2011
@@ -5,15 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
+ */
package org.apache.catalina.connector;
import org.apache.catalina.Container;
@@ -53,7 +53,7 @@ public class MapperListener extends Life
* Associated mapper.
*/
private Mapper mapper = null;
-
+
/**
* Associated connector
*/
@@ -69,7 +69,7 @@ public class MapperListener extends Life
/**
* The domain (effectively the engine) this mapper is associated with
*/
- private String domain = null;
+ private final String domain = null;
// ----------------------------------------------------------- Constructors
@@ -89,7 +89,7 @@ public class MapperListener extends Life
return this.connector.toString();
}
-
+
// ------------------------------------------------------- Lifecycle Methods
@Override
@@ -101,10 +101,10 @@ public class MapperListener extends Life
// MBean listener won't be notified as those components will have
// already registered their MBeans
findDefaultHost();
-
+
Engine engine = (Engine) connector.getService().getContainer();
addListeners(engine);
-
+
Container[] conHosts = engine.findChildren();
for (Container conHost : conHosts) {
Host host = (Host) conHost;
@@ -114,7 +114,7 @@ public class MapperListener extends Life
}
}
}
-
+
@Override
public void stopInternal() throws LifecycleException {
@@ -194,55 +194,55 @@ public class MapperListener extends Life
String hostName = wrapper.getParent().getParent().getName();
String mapping = (String) event.getData();
-
+
mapper.removeWrapper(hostName, contextPath, version, mapping);
} else if (Context.ADD_WELCOME_FILE_EVENT.equals(event.getType())) {
// Handle dynamically adding welcome files
Context context = (Context) event.getSource();
-
+
String hostName = context.getParent().getName();
String contextPath = context.getPath();
if ("/".equals(contextPath)) {
contextPath = "";
}
-
+
String welcomeFile = (String) event.getData();
-
+
mapper.addWelcomeFile(hostName, contextPath,
context.getWebappVersion(), welcomeFile);
} else if (Context.REMOVE_WELCOME_FILE_EVENT.equals(event.getType())) {
// Handle dynamically removing welcome files
Context context = (Context) event.getSource();
-
+
String hostName = context.getParent().getName();
String contextPath = context.getPath();
if ("/".equals(contextPath)) {
contextPath = "";
}
-
+
String welcomeFile = (String) event.getData();
-
+
mapper.removeWelcomeFile(hostName, contextPath,
context.getWebappVersion(), welcomeFile);
} else if (Context.CLEAR_WELCOME_FILES_EVENT.equals(event.getType())) {
// Handle dynamically clearing welcome files
Context context = (Context) event.getSource();
-
+
String hostName = context.getParent().getName();
String contextPath = context.getPath();
if ("/".equals(contextPath)) {
contextPath = "";
}
-
+
mapper.clearWelcomeFiles(hostName, contextPath,
context.getWebappVersion());
}
}
-
+
// ------------------------------------------------------ Protected Methods
private void findDefaultHost() {
@@ -254,14 +254,14 @@ public class MapperListener extends Life
if (defaultHost != null && defaultHost.length() >0) {
Container[] containers = engine.findChildren();
-
+
for (Container container : containers) {
Host host = (Host) container;
if (defaultHost.equalsIgnoreCase(host.getName())) {
found = true;
break;
}
-
+
String[] aliases = host.findAliases();
for (String alias : aliases) {
if (defaultHost.equalsIgnoreCase(alias)) {
@@ -280,15 +280,15 @@ public class MapperListener extends Life
}
}
-
+
/**
* Register host.
*/
private void registerHost(Host host) {
-
+
String[] aliases = host.findAliases();
mapper.addHost(host.getName(), aliases, host);
-
+
for (Container container : host.findChildren()) {
if (container.getState().isAvailable()) {
registerContext((Context) container);
@@ -307,15 +307,16 @@ public class MapperListener extends Life
private void unregisterHost(Host host) {
String hostname = host.getName();
-
+
mapper.removeHost(hostname);
- if(log.isDebugEnabled())
+ if(log.isDebugEnabled()) {
log.debug(sm.getString("mapperListener.unregisterHost", hostname,
domain, connector));
+ }
}
-
+
/**
* Unregister wrapper.
*/
@@ -331,18 +332,18 @@ public class MapperListener extends Life
String hostName = wrapper.getParent().getParent().getName();
String[] mappings = wrapper.findMappings();
-
+
for (String mapping : mappings) {
mapper.removeWrapper(hostName, contextPath, version, mapping);
}
-
+
if(log.isDebugEnabled()) {
log.debug(sm.getString("mapperListener.unregisterWrapper",
wrapperName, contextPath, connector));
}
}
-
+
/**
* Register context.
*/
@@ -353,7 +354,7 @@ public class MapperListener extends Life
contextPath = "";
}
Container host = context.getParent();
-
+
javax.naming.Context resources = context.getResources();
String[] welcomeFiles = context.findWelcomeFiles();
@@ -387,9 +388,10 @@ public class MapperListener extends Life
}
String hostName = context.getParent().getName();
- if(log.isDebugEnabled())
+ if(log.isDebugEnabled()) {
log.debug(sm.getString("mapperListener.unregisterContext",
contextPath, connector));
+ }
mapper.removeContextVersion(hostName, contextPath,
context.getWebappVersion());
@@ -409,7 +411,7 @@ public class MapperListener extends Life
}
String version = ((Context) wrapper.getParent()).getWebappVersion();
String hostName = context.getParent().getName();
-
+
String[] mappings = wrapper.findMappings();
for (String mapping : mappings) {
@@ -452,7 +454,7 @@ public class MapperListener extends Life
/**
* Add this mapper to the container and all child containers
- *
+ *
* @param container
*/
private void addListeners(Container container) {
@@ -466,7 +468,7 @@ public class MapperListener extends Life
/**
* Remove this mapper from the container and all child containers
- *
+ *
* @param container
*/
private void removeListeners(Container container) {
Modified: tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java?rev=1187753&r1=1187752&r2=1187753&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java Sat Oct 22 19:21:08 2011
@@ -5,16 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
-
+ */
package org.apache.catalina.connector;
@@ -34,7 +33,7 @@ import org.apache.tomcat.util.buf.C2BCon
/**
* The buffer used by Tomcat response. This is a derivative of the Tomcat 3.3
- * OutputBuffer, with the removal of some of the state handling (which in
+ * OutputBuffer, with the removal of some of the state handling (which in
* Coyote is mostly the Processor's responsibility).
*
* @author Costin Manolache
@@ -47,7 +46,7 @@ public class OutputBuffer extends Writer
// -------------------------------------------------------------- Constants
- public static final String DEFAULT_ENCODING =
+ public static final String DEFAULT_ENCODING =
org.apache.coyote.Constants.DEFAULT_CHARACTER_ENCODING;
public static final int DEFAULT_BUFFER_SIZE = 8*1024;
@@ -58,7 +57,7 @@ public class OutputBuffer extends Writer
/**
* The byte buffer.
*/
- private ByteChunk bb;
+ private final ByteChunk bb;
/**
@@ -94,7 +93,7 @@ public class OutputBuffer extends Writer
/**
* Byte chunk used to output bytes.
*/
- private ByteChunk outputChunk = new ByteChunk();
+ private final ByteChunk outputChunk = new ByteChunk();
/**
@@ -149,7 +148,7 @@ public class OutputBuffer extends Writer
/**
* Alternate constructor which allows specifying the initial buffer size.
- *
+ *
* @param size Buffer size to use
*/
public OutputBuffer(int size) {
@@ -166,7 +165,7 @@ public class OutputBuffer extends Writer
/**
* Associated Coyote response.
- *
+ *
* @param coyoteResponse Associated Coyote response
*/
public void setResponse(Response coyoteResponse) {
@@ -176,7 +175,7 @@ public class OutputBuffer extends Writer
/**
* Get associated Coyote response.
- *
+ *
* @return the associated Coyote response
*/
public Response getResponse() {
@@ -186,7 +185,7 @@ public class OutputBuffer extends Writer
/**
* Is the response output suspended ?
- *
+ *
* @return suspended flag value
*/
public boolean isSuspended() {
@@ -196,7 +195,7 @@ public class OutputBuffer extends Writer
/**
* Set the suspended flag.
- *
+ *
* @param suspended New suspended flag value
*/
public void setSuspended(boolean suspended) {
@@ -206,7 +205,7 @@ public class OutputBuffer extends Writer
/**
* Is the response output closed ?
- *
+ *
* @return closed flag value
*/
public boolean isClosed() {
@@ -221,23 +220,23 @@ public class OutputBuffer extends Writer
* Recycle the output buffer.
*/
public void recycle() {
-
+
initial = true;
bytesWritten = 0;
charsWritten = 0;
-
- bb.recycle();
+
+ bb.recycle();
closed = false;
doFlush = false;
suspended = false;
-
+
if (conv!= null) {
conv.recycle();
}
-
+
gotEnc = false;
enc = null;
-
+
}
@@ -247,24 +246,26 @@ public class OutputBuffer extends Writer
public void clearEncoders() {
encoders.clear();
}
-
-
+
+
/**
- * Close the output buffer. This tries to calculate the response size if
+ * Close the output buffer. This tries to calculate the response size if
* the response has not been committed yet.
- *
+ *
* @throws IOException An underlying IOException occurred
*/
@Override
public void close()
throws IOException {
- if (closed)
+ if (closed) {
return;
- if (suspended)
+ }
+ if (suspended) {
return;
+ }
- if ((!coyoteResponse.isCommitted())
+ if ((!coyoteResponse.isCommitted())
&& (coyoteResponse.getContentLengthLong() == -1)) {
// If this didn't cause a commit of the response, the final content
// length can be calculated
@@ -282,7 +283,7 @@ public class OutputBuffer extends Writer
Request req = (Request) coyoteResponse.getRequest().getNote(
CoyoteAdapter.ADAPTER_NOTES);
req.inputBuffer.close();
-
+
coyoteResponse.finish();
}
@@ -290,7 +291,7 @@ public class OutputBuffer extends Writer
/**
* Flush bytes or chars contained in the buffer.
- *
+ *
* @throws IOException An underlying IOException occurred
*/
@Override
@@ -302,14 +303,15 @@ public class OutputBuffer extends Writer
/**
* Flush bytes or chars contained in the buffer.
- *
+ *
* @throws IOException An underlying IOException occurred
*/
protected void doFlush(boolean realFlush)
throws IOException {
- if (suspended)
+ if (suspended) {
return;
+ }
try {
doFlush = true;
@@ -325,7 +327,7 @@ public class OutputBuffer extends Writer
}
if (realFlush) {
- coyoteResponse.action(ActionCode.CLIENT_FLUSH,
+ coyoteResponse.action(ActionCode.CLIENT_FLUSH,
coyoteResponse);
// If some exception occurred earlier, or if some IOE occurred
// here, notify the servlet with an IOE
@@ -341,24 +343,26 @@ public class OutputBuffer extends Writer
// ------------------------------------------------- Bytes Handling Methods
- /**
+ /**
* Sends the buffer data to the client output, checking the
* state of Response and calling the right interceptors.
- *
+ *
* @param buf Byte buffer to be written to the response
* @param off Offset
* @param cnt Length
- *
+ *
* @throws IOException An underlying IOException occurred
*/
@Override
public void realWriteBytes(byte buf[], int off, int cnt)
throws IOException {
- if (closed)
+ if (closed) {
return;
- if (coyoteResponse == null)
+ }
+ if (coyoteResponse == null) {
return;
+ }
// If we really have something to write
if (cnt > 0) {
@@ -379,19 +383,21 @@ public class OutputBuffer extends Writer
public void write(byte b[], int off, int len) throws IOException {
- if (suspended)
+ if (suspended) {
return;
+ }
writeBytes(b, off, len);
}
- private void writeBytes(byte b[], int off, int len)
+ private void writeBytes(byte b[], int off, int len)
throws IOException {
- if (closed)
+ if (closed) {
return;
+ }
bb.append(b, off, len);
bytesWritten += len;
@@ -408,8 +414,9 @@ public class OutputBuffer extends Writer
public void writeByte(int b)
throws IOException {
- if (suspended)
+ if (suspended) {
return;
+ }
bb.append((byte) b);
bytesWritten++;
@@ -424,13 +431,14 @@ public class OutputBuffer extends Writer
public void write(int c)
throws IOException {
- if (suspended)
+ if (suspended) {
return;
+ }
conv.convert((char) c);
conv.flushBuffer();
charsWritten++;
-
+
}
@@ -438,8 +446,9 @@ public class OutputBuffer extends Writer
public void write(char c[])
throws IOException {
- if (suspended)
+ if (suspended) {
return;
+ }
write(c, 0, c.length);
@@ -450,8 +459,9 @@ public class OutputBuffer extends Writer
public void write(char c[], int off, int len)
throws IOException {
- if (suspended)
+ if (suspended) {
return;
+ }
conv.convert(c, off, len);
conv.flushBuffer();
@@ -467,12 +477,14 @@ public class OutputBuffer extends Writer
public void write(String s, int off, int len)
throws IOException {
- if (suspended)
+ if (suspended) {
return;
+ }
charsWritten += len;
- if (s == null)
+ if (s == null) {
s = "null";
+ }
conv.convert(s, off, len);
conv.flushBuffer();
@@ -483,15 +495,17 @@ public class OutputBuffer extends Writer
public void write(String s)
throws IOException {
- if (suspended)
+ if (suspended) {
return;
+ }
- if (s == null)
+ if (s == null) {
s = "null";
+ }
conv.convert(s);
conv.flushBuffer();
- }
+ }
public void setEncoding(String s) {
@@ -499,27 +513,30 @@ public class OutputBuffer extends Writer
}
- public void checkConverter()
+ public void checkConverter()
throws IOException {
- if (!gotEnc)
+ if (!gotEnc) {
setConverter();
+ }
}
- protected void setConverter()
+ protected void setConverter()
throws IOException {
- if (coyoteResponse != null)
+ if (coyoteResponse != null) {
enc = coyoteResponse.getCharacterEncoding();
+ }
gotEnc = true;
- if (enc == null)
+ if (enc == null) {
enc = DEFAULT_ENCODING;
+ }
conv = encoders.get(enc);
if (conv == null) {
-
+
if (Globals.IS_SECURITY_ENABLED){
try{
conv = AccessController.doPrivileged(
@@ -531,32 +548,33 @@ public class OutputBuffer extends Writer
}
}
- );
+ );
}catch(PrivilegedActionException ex){
Exception e = ex.getException();
- if (e instanceof IOException)
- throw (IOException)e;
+ if (e instanceof IOException) {
+ throw (IOException)e;
+ }
}
} else {
conv = new C2BConverter(bb, enc);
}
-
+
encoders.put(enc, conv);
}
}
-
+
// -------------------- BufferedOutputStream compatibility
public long getContentWritten() {
return bytesWritten + charsWritten;
}
-
- /**
+
+ /**
* True if this buffer hasn't been used ( since recycle() ) -
- * i.e. no chars or bytes have been added to the buffer.
+ * i.e. no chars or bytes have been added to the buffer.
*/
public boolean isNew() {
return (bytesWritten == 0) && (charsWritten == 0);
@@ -578,7 +596,7 @@ public class OutputBuffer extends Writer
gotEnc = false;
enc = null;
initial = true;
-
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org