This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push: new f37694f2cf Code clean-up. No functional change. f37694f2cf is described below commit f37694f2cfdd07e228df472bd749f8be3d7bf901 Author: Mark Thomas <ma...@apache.org> AuthorDate: Mon Jul 22 17:13:03 2024 +0100 Code clean-up. No functional change. --- .../coyote/http11/AbstractHttp11JsseProtocol.java | 6 ++-- .../apache/coyote/http11/Http11InputBuffer.java | 2 ++ java/org/apache/coyote/http11/Http11Processor.java | 10 +++--- .../coyote/http11/filters/BufferedInputFilter.java | 9 +++-- .../coyote/http11/filters/ChunkedInputFilter.java | 36 ++++++++++---------- .../coyote/http11/filters/ChunkedOutputFilter.java | 38 ++++++++++------------ .../coyote/http11/filters/GzipOutputFilter.java | 22 +++++++------ .../coyote/http11/filters/IdentityInputFilter.java | 8 ++--- .../http11/filters/SavedRequestInputFilter.java | 10 +++--- .../coyote/http11/filters/VoidInputFilter.java | 6 ++-- .../coyote/http11/filters/VoidOutputFilter.java | 5 ++- .../http11/upgrade/InternalHttpUpgradeHandler.java | 9 +++-- .../upgrade/UpgradeApplicationBufferHandler.java | 4 +-- .../coyote/http11/upgrade/UpgradeGroupInfo.java | 6 +++- .../apache/coyote/http11/upgrade/UpgradeInfo.java | 19 +++++++---- .../http11/upgrade/UpgradeProcessorExternal.java | 3 +- .../http11/upgrade/UpgradeServletInputStream.java | 16 +++------ .../http11/upgrade/UpgradeServletOutputStream.java | 15 +++------ 18 files changed, 110 insertions(+), 114 deletions(-) diff --git a/java/org/apache/coyote/http11/AbstractHttp11JsseProtocol.java b/java/org/apache/coyote/http11/AbstractHttp11JsseProtocol.java index 2ea65972fd..e8e1cc3941 100644 --- a/java/org/apache/coyote/http11/AbstractHttp11JsseProtocol.java +++ b/java/org/apache/coyote/http11/AbstractHttp11JsseProtocol.java @@ -21,15 +21,15 @@ import org.apache.tomcat.util.net.openssl.OpenSSLImplementation; public abstract class AbstractHttp11JsseProtocol<S> extends AbstractHttp11Protocol<S> { - public AbstractHttp11JsseProtocol(AbstractJsseEndpoint<S, ?> endpoint) { + public AbstractHttp11JsseProtocol(AbstractJsseEndpoint<S,?> endpoint) { super(endpoint); } @Override - protected AbstractJsseEndpoint<S, ?> getEndpoint() { + protected AbstractJsseEndpoint<S,?> getEndpoint() { // Over-ridden to add cast - return (AbstractJsseEndpoint<S, ?>) super.getEndpoint(); + return (AbstractJsseEndpoint<S,?>) super.getEndpoint(); } diff --git a/java/org/apache/coyote/http11/Http11InputBuffer.java b/java/org/apache/coyote/http11/Http11InputBuffer.java index 3e4137d1aa..2416824b3d 100644 --- a/java/org/apache/coyote/http11/Http11InputBuffer.java +++ b/java/org/apache/coyote/http11/Http11InputBuffer.java @@ -658,6 +658,7 @@ public class Http11InputBuffer implements InputBuffer, ApplicationBufferHandler /** * Available bytes in the buffers for the current request. Note that when requests are pipelined, the data in * byteBuffer may relate to the next request rather than this one. + * * @return the amount of bytes available, 0 if none, and 1 if there was an IO error to trigger a read */ int available(boolean read) { @@ -701,6 +702,7 @@ public class Http11InputBuffer implements InputBuffer, ApplicationBufferHandler /** * Has all of the request body been read? There are subtle differences between this and available() > 0 primarily * because of having to handle faking non-blocking reads with the blocking IO connector. + * * @return {@code true} if the request has been fully read */ boolean isFinished() { diff --git a/java/org/apache/coyote/http11/Http11Processor.java b/java/org/apache/coyote/http11/Http11Processor.java index 1389185e90..a388e89007 100644 --- a/java/org/apache/coyote/http11/Http11Processor.java +++ b/java/org/apache/coyote/http11/Http11Processor.java @@ -167,9 +167,9 @@ public class Http11Processor extends AbstractProcessor { outputBuffer.addFilter(new IdentityOutputFilter()); // Create and add the chunked filters. - inputBuffer.addFilter( - new ChunkedInputFilter(request, protocol.getMaxTrailerSize(), protocol.getAllowedTrailerHeadersInternal(), - protocol.getMaxExtensionSize(), protocol.getMaxSwallowSize())); + inputBuffer.addFilter(new ChunkedInputFilter(request, protocol.getMaxTrailerSize(), + protocol.getAllowedTrailerHeadersInternal(), protocol.getMaxExtensionSize(), + protocol.getMaxSwallowSize())); outputBuffer.addFilter(new ChunkedOutputFilter()); // Create and add the void filters. @@ -998,8 +998,8 @@ public class Http11Processor extends AbstractProcessor { } if (protocol.getUseKeepAliveResponseHeader()) { - boolean connectionKeepAlivePresent = isConnectionToken(request.getMimeHeaders(), - Constants.KEEP_ALIVE_HEADER_VALUE_TOKEN); + boolean connectionKeepAlivePresent = + isConnectionToken(request.getMimeHeaders(), Constants.KEEP_ALIVE_HEADER_VALUE_TOKEN); if (connectionKeepAlivePresent) { int keepAliveTimeout = protocol.getKeepAliveTimeout(); diff --git a/java/org/apache/coyote/http11/filters/BufferedInputFilter.java b/java/org/apache/coyote/http11/filters/BufferedInputFilter.java index 8727f4d1a6..455ffb882a 100644 --- a/java/org/apache/coyote/http11/filters/BufferedInputFilter.java +++ b/java/org/apache/coyote/http11/filters/BufferedInputFilter.java @@ -29,8 +29,8 @@ import org.apache.tomcat.util.net.ApplicationBufferHandler; import org.apache.tomcat.util.res.StringManager; /** - * Input filter responsible for reading and buffering the request body, so that - * it does not interfere with client SSL handshake messages. + * Input filter responsible for reading and buffering the request body, so that it does not interfere with client SSL + * handshake messages. */ public class BufferedInputFilter implements InputFilter, ApplicationBufferHandler { @@ -63,8 +63,7 @@ public class BufferedInputFilter implements InputFilter, ApplicationBufferHandle /** - * Set the buffering limit. This should be reset every time the buffer is - * used. + * Set the buffering limit. This should be reset every time the buffer is used. * * @param limit The maximum number of bytes that will be buffered */ @@ -103,7 +102,7 @@ public class BufferedInputFilter implements InputFilter, ApplicationBufferHandle tempRead = null; } } - } catch(IOException | BufferOverflowException ioe) { + } catch (IOException | BufferOverflowException ioe) { // No need for i18n - this isn't going to get logged anywhere throw new IllegalStateException(sm.getString("bufferedInputFilter.bodySize", ioe.getMessage())); } diff --git a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java index 0f988328ec..36389576d4 100644 --- a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java +++ b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java @@ -36,8 +36,8 @@ import org.apache.tomcat.util.net.ApplicationBufferHandler; import org.apache.tomcat.util.res.StringManager; /** - * Chunked input filter. Parses chunked data according to - * <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.6.1">http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.6.1</a><br> + * Chunked input filter. Parses chunked data according to <a href= + * "http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.6.1">http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.6.1</a><br> * * @author Remy Maucherat */ @@ -55,8 +55,7 @@ public class ChunkedInputFilter implements InputFilter, ApplicationBufferHandler // ----------------------------------------------------- Static Initializer static { - ENCODING.setBytes(ENCODING_NAME.getBytes(StandardCharsets.ISO_8859_1), - 0, ENCODING_NAME.length()); + ENCODING.setBytes(ENCODING_NAME.getBytes(StandardCharsets.ISO_8859_1), 0, ENCODING_NAME.length()); } @@ -247,7 +246,9 @@ public class ChunkedInputFilter implements InputFilter, ApplicationBufferHandler /** * Read bytes from the previous buffer. + * * @return The byte count which has been read + * * @throws IOException Read error */ protected int readBytes() throws IOException { @@ -305,18 +306,15 @@ public class ChunkedInputFilter implements InputFilter, ApplicationBufferHandler /** - * Parse the header of a chunk. - * A chunk header can look like one of the following:<br> + * Parse the header of a chunk. A chunk header can look like one of the following:<br> * A10CRLF<br> * F23;chunk-extension to be ignoredCRLF - * * <p> - * The letters before CRLF or ';' (whatever comes first) must be valid hex - * digits. We should not parse F23IAMGONNAMESSTHISUP34CRLF as a valid - * header according to the spec. + * The letters before CRLF or ';' (whatever comes first) must be valid hex digits. We should not parse + * F23IAMGONNAMESSTHISUP34CRLF as a valid header according to the spec. * * @return {@code true} if the read is complete or {@code false if incomplete}. In complete reads can only happen - * with non-blocking I/O. + * with non-blocking I/O. * * @throws IOException Read error */ @@ -417,7 +415,7 @@ public class ChunkedInputFilter implements InputFilter, ApplicationBufferHandler * Parse CRLF at end of chunk. * * @return {@code true} if the read is complete or {@code false if incomplete}. In complete reads can only happen - * with non-blocking I/O. + * with non-blocking I/O. * * @throws IOException An error occurred parsing CRLF */ @@ -457,7 +455,7 @@ public class ChunkedInputFilter implements InputFilter, ApplicationBufferHandler * Parse end chunk data. * * @return {@code true} if the read is complete or {@code false if incomplete}. In complete reads can only happen - * with non-blocking I/O. + * with non-blocking I/O. * * @throws IOException Error propagation */ @@ -477,14 +475,14 @@ public class ChunkedInputFilter implements InputFilter, ApplicationBufferHandler request.getMimeTrailerFields().filter(allowedTrailerHeaders); if (request.getReadListener() != null) { /* - * Perform the dispatch back to the container for the onAllDataRead() event. For non-chunked input - * this would be performed when isReady() is next called. + * Perform the dispatch back to the container for the onAllDataRead() event. For non-chunked input this + * would be performed when isReady() is next called. * * Chunked input returns one chunk at a time for non-blocking reads. A consequence of this is that - * reading the final chunk returns -1 which signals the end of stream. The application code reading - * the request body probably won't call isReady() after receiving the -1 return value since it - * already knows it is at end of stream. Therefore we trigger the dispatch back to the container - * here which in turn ensures the onAllDataRead() event is fired. + * reading the final chunk returns -1 which signals the end of stream. The application code reading the + * request body probably won't call isReady() after receiving the -1 return value since it already knows + * it is at end of stream. Therefore we trigger the dispatch back to the container here which in turn + * ensures the onAllDataRead() event is fired. */ request.action(ActionCode.DISPATCH_READ, null); request.action(ActionCode.DISPATCH_EXECUTE, null); diff --git a/java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java b/java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java index 5879bbf2ea..1963b58954 100644 --- a/java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java +++ b/java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java @@ -39,10 +39,9 @@ import org.apache.tomcat.util.buf.HexUtils; */ public class ChunkedOutputFilter implements OutputFilter { - private static final byte[] LAST_CHUNK_BYTES = {(byte) '0', (byte) '\r', (byte) '\n'}; - private static final byte[] CRLF_BYTES = {(byte) '\r', (byte) '\n'}; - private static final byte[] END_CHUNK_BYTES = - {(byte) '0', (byte) '\r', (byte) '\n', (byte) '\r', (byte) '\n'}; + private static final byte[] LAST_CHUNK_BYTES = { (byte) '0', (byte) '\r', (byte) '\n' }; + private static final byte[] CRLF_BYTES = { (byte) '\r', (byte) '\n' }; + private static final byte[] END_CHUNK_BYTES = { (byte) '0', (byte) '\r', (byte) '\n', (byte) '\r', (byte) '\n' }; private static final Set<String> disallowedTrailerFieldNames = new HashSet<>(); @@ -176,22 +175,21 @@ public class ChunkedOutputFilter implements OutputFilter { buffer.doWrite(lastChunk); lastChunk.position(0).limit(lastChunk.capacity()); - ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); - - try (OutputStreamWriter osw = new OutputStreamWriter(baos, StandardCharsets.ISO_8859_1)) { - for (Map.Entry<String, String> trailerField : trailerFields.entrySet()) { - // Ignore disallowed headers - if (disallowedTrailerFieldNames.contains( - trailerField.getKey().toLowerCase(Locale.ENGLISH))) { - continue; - } - osw.write(trailerField.getKey()); - osw.write(':'); - osw.write(' '); - osw.write(trailerField.getValue()); - osw.write("\r\n"); - } - } + ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); + + try (OutputStreamWriter osw = new OutputStreamWriter(baos, StandardCharsets.ISO_8859_1)) { + for (Map.Entry<String,String> trailerField : trailerFields.entrySet()) { + // Ignore disallowed headers + if (disallowedTrailerFieldNames.contains(trailerField.getKey().toLowerCase(Locale.ENGLISH))) { + continue; + } + osw.write(trailerField.getKey()); + osw.write(':'); + osw.write(' '); + osw.write(trailerField.getValue()); + osw.write("\r\n"); + } + } buffer.doWrite(ByteBuffer.wrap(baos.toByteArray())); diff --git a/java/org/apache/coyote/http11/filters/GzipOutputFilter.java b/java/org/apache/coyote/http11/filters/GzipOutputFilter.java index 16243b0cf2..001f92c712 100644 --- a/java/org/apache/coyote/http11/filters/GzipOutputFilter.java +++ b/java/org/apache/coyote/http11/filters/GzipOutputFilter.java @@ -88,8 +88,7 @@ public class GzipOutputFilter implements OutputFilter { // --------------------------------------------------- OutputFilter Methods /** - * {@inheritDoc} - * Added to allow flushing to happen for the gzip'ed outputstream. + * {@inheritDoc} Added to allow flushing to happen for the gzip'ed outputstream. */ @Override public void flush() throws IOException { @@ -142,26 +141,29 @@ public class GzipOutputFilter implements OutputFilter { // ------------------------------------------- FakeOutputStream Inner Class - protected class FakeOutputStream - extends OutputStream { + protected class FakeOutputStream extends OutputStream { protected final ByteBuffer outputChunk = ByteBuffer.allocate(1); + @Override - public void write(int b) - throws IOException { + public void write(int b) throws IOException { // Shouldn't get used for good performance, but is needed for // compatibility with Sun JDK 1.4.0 outputChunk.put(0, (byte) (b & 0xff)); buffer.doWrite(outputChunk); } + @Override - public void write(byte[] b, int off, int len) - throws IOException { + public void write(byte[] b, int off, int len) throws IOException { buffer.doWrite(ByteBuffer.wrap(b, off, len)); } + @Override - public void flush() throws IOException {/*NOOP*/} + public void flush() throws IOException { + /* NOOP */} + @Override - public void close() throws IOException {/*NOOP*/} + public void close() throws IOException { + /* NOOP */} } diff --git a/java/org/apache/coyote/http11/filters/IdentityInputFilter.java b/java/org/apache/coyote/http11/filters/IdentityInputFilter.java index ef494a5614..e396360a81 100644 --- a/java/org/apache/coyote/http11/filters/IdentityInputFilter.java +++ b/java/org/apache/coyote/http11/filters/IdentityInputFilter.java @@ -46,8 +46,7 @@ public class IdentityInputFilter implements InputFilter, ApplicationBufferHandle // ----------------------------------------------------- Static Initializer static { - ENCODING.setBytes(ENCODING_NAME.getBytes(StandardCharsets.ISO_8859_1), - 0, ENCODING_NAME.length()); + ENCODING.setBytes(ENCODING_NAME.getBytes(StandardCharsets.ISO_8859_1), 0, ENCODING_NAME.length()); } @@ -126,8 +125,7 @@ public class IdentityInputFilter implements InputFilter, ApplicationBufferHandle /** - * {@inheritDoc} - * Read the content length from the request. + * {@inheritDoc} Read the content length from the request. */ @Override public void setRequest(Request request) { @@ -147,7 +145,7 @@ public class IdentityInputFilter implements InputFilter, ApplicationBufferHandle int nread = buffer.doRead(this); tempRead = null; - if (nread > 0 ) { + if (nread > 0) { swallowed += nread; remaining = remaining - nread; if (maxSwallowSizeExceeded && swallowed > maxSwallowSize) { diff --git a/java/org/apache/coyote/http11/filters/SavedRequestInputFilter.java b/java/org/apache/coyote/http11/filters/SavedRequestInputFilter.java index a10063005b..9bead7331e 100644 --- a/java/org/apache/coyote/http11/filters/SavedRequestInputFilter.java +++ b/java/org/apache/coyote/http11/filters/SavedRequestInputFilter.java @@ -25,8 +25,7 @@ import org.apache.tomcat.util.buf.ByteChunk; import org.apache.tomcat.util.net.ApplicationBufferHandler; /** - * Input filter responsible for replaying the request body when restoring the - * saved request after FORM authentication. + * Input filter responsible for replaying the request body when restoring the saved request after FORM authentication. */ public class SavedRequestInputFilter implements InputFilter { @@ -46,7 +45,7 @@ public class SavedRequestInputFilter implements InputFilter { @Override public int doRead(ApplicationBufferHandler handler) throws IOException { - if(input.getStart()>= input.getEnd()) { + if (input.getStart() >= input.getEnd()) { return -1; } @@ -58,8 +57,7 @@ public class SavedRequestInputFilter implements InputFilter { } /** - * {@inheritDoc} - * Set the content length on the request. + * {@inheritDoc} Set the content length on the request. */ @Override public void setRequest(org.apache.coyote.Request request) { @@ -81,6 +79,7 @@ public class SavedRequestInputFilter implements InputFilter { /** * Set the next buffer in the filter pipeline (has no effect). + * * @param buffer ignored */ @Override @@ -95,6 +94,7 @@ public class SavedRequestInputFilter implements InputFilter { /** * End the current request (has no effect). + * * @return 0 */ @Override diff --git a/java/org/apache/coyote/http11/filters/VoidInputFilter.java b/java/org/apache/coyote/http11/filters/VoidInputFilter.java index 5db6fac975..65a0c4ecd2 100644 --- a/java/org/apache/coyote/http11/filters/VoidInputFilter.java +++ b/java/org/apache/coyote/http11/filters/VoidInputFilter.java @@ -26,8 +26,7 @@ import org.apache.tomcat.util.buf.ByteChunk; import org.apache.tomcat.util.net.ApplicationBufferHandler; /** - * Void input filter, which returns -1 when attempting a read. Used with a GET, - * HEAD, or a similar request. + * Void input filter, which returns -1 when attempting a read. Used with a GET, HEAD, or a similar request. * * @author Remy Maucherat */ @@ -43,8 +42,7 @@ public class VoidInputFilter implements InputFilter { // ----------------------------------------------------- Static Initializer static { - ENCODING.setBytes(ENCODING_NAME.getBytes(StandardCharsets.ISO_8859_1), - 0, ENCODING_NAME.length()); + ENCODING.setBytes(ENCODING_NAME.getBytes(StandardCharsets.ISO_8859_1), 0, ENCODING_NAME.length()); } diff --git a/java/org/apache/coyote/http11/filters/VoidOutputFilter.java b/java/org/apache/coyote/http11/filters/VoidOutputFilter.java index edf38f9cb6..1b3aaf7d2b 100644 --- a/java/org/apache/coyote/http11/filters/VoidOutputFilter.java +++ b/java/org/apache/coyote/http11/filters/VoidOutputFilter.java @@ -24,8 +24,7 @@ import org.apache.coyote.http11.HttpOutputBuffer; import org.apache.coyote.http11.OutputFilter; /** - * Void output filter, which silently swallows bytes written. Used with a 204 - * status (no content) or a HEAD request. + * Void output filter, which silently swallows bytes written. Used with a 204 status (no content) or a HEAD request. * * @author Remy Maucherat */ @@ -75,7 +74,7 @@ public class VoidOutputFilter implements OutputFilter { @Override - public void end() throws IOException { + public void end() throws IOException { buffer.end(); } } diff --git a/java/org/apache/coyote/http11/upgrade/InternalHttpUpgradeHandler.java b/java/org/apache/coyote/http11/upgrade/InternalHttpUpgradeHandler.java index e2c7799b15..9212eeb13d 100644 --- a/java/org/apache/coyote/http11/upgrade/InternalHttpUpgradeHandler.java +++ b/java/org/apache/coyote/http11/upgrade/InternalHttpUpgradeHandler.java @@ -25,32 +25,37 @@ import org.apache.tomcat.util.net.SocketWrapperBase; /** - * This Tomcat specific interface is implemented by handlers that require direct - * access to Tomcat's I/O layer rather than going through the Servlet API. + * This Tomcat specific interface is implemented by handlers that require direct access to Tomcat's I/O layer rather + * than going through the Servlet API. */ public interface InternalHttpUpgradeHandler extends HttpUpgradeHandler { /** * Process the specified event. + * * @param status the event + * * @return the status following the event */ SocketState upgradeDispatch(SocketEvent status); /** * Check for a possible timeout. + * * @param now the time to use for the timeout check */ void timeoutAsync(long now); /** * Associate with the specified socket. + * * @param wrapper the socket */ void setSocketWrapper(SocketWrapperBase<?> wrapper); /** * Associate with the specified SSL support. + * * @param sslSupport the SSL support */ void setSslSupport(SSLSupport sslSupport); diff --git a/java/org/apache/coyote/http11/upgrade/UpgradeApplicationBufferHandler.java b/java/org/apache/coyote/http11/upgrade/UpgradeApplicationBufferHandler.java index b551aabe11..264f79bb50 100644 --- a/java/org/apache/coyote/http11/upgrade/UpgradeApplicationBufferHandler.java +++ b/java/org/apache/coyote/http11/upgrade/UpgradeApplicationBufferHandler.java @@ -21,8 +21,8 @@ import java.nio.ByteBuffer; import org.apache.tomcat.util.net.ApplicationBufferHandler; /** - * Trivial implementation of {@link ApplicationBufferHandler} to support saving - * of HTTP request bodies during an HTTP/1.1 upgrade. + * Trivial implementation of {@link ApplicationBufferHandler} to support saving of HTTP request bodies during an + * HTTP/1.1 upgrade. */ public class UpgradeApplicationBufferHandler implements ApplicationBufferHandler { diff --git a/java/org/apache/coyote/http11/upgrade/UpgradeGroupInfo.java b/java/org/apache/coyote/http11/upgrade/UpgradeGroupInfo.java index 638d0d23d2..fe64cbfea5 100644 --- a/java/org/apache/coyote/http11/upgrade/UpgradeGroupInfo.java +++ b/java/org/apache/coyote/http11/upgrade/UpgradeGroupInfo.java @@ -23,7 +23,7 @@ import java.util.concurrent.atomic.LongAdder; import org.apache.tomcat.util.modeler.BaseModelMBean; /** - * This aggregates the data collected from each UpgradeInfo instance. + * This aggregates the data collected from each UpgradeInfo instance. */ public class UpgradeGroupInfo extends BaseModelMBean { @@ -59,6 +59,7 @@ public class UpgradeGroupInfo extends BaseModelMBean { } return bytes; } + public void setBytesReceived(long bytesReceived) { deadBytesReceived.reset(); if (bytesReceived != 0) { @@ -77,6 +78,7 @@ public class UpgradeGroupInfo extends BaseModelMBean { } return bytes; } + public void setBytesSent(long bytesSent) { deadBytesSent.reset(); if (bytesSent != 0) { @@ -95,6 +97,7 @@ public class UpgradeGroupInfo extends BaseModelMBean { } return msgs; } + public void setMsgsReceived(long msgsReceived) { deadMsgsReceived.reset(); if (msgsReceived != 0) { @@ -113,6 +116,7 @@ public class UpgradeGroupInfo extends BaseModelMBean { } return msgs; } + public void setMsgsSent(long msgsSent) { deadMsgsSent.reset(); if (msgsSent != 0) { diff --git a/java/org/apache/coyote/http11/upgrade/UpgradeInfo.java b/java/org/apache/coyote/http11/upgrade/UpgradeInfo.java index eb3313c6ac..ecce76d5f2 100644 --- a/java/org/apache/coyote/http11/upgrade/UpgradeInfo.java +++ b/java/org/apache/coyote/http11/upgrade/UpgradeInfo.java @@ -17,13 +17,11 @@ package org.apache.coyote.http11.upgrade; /** - * Structure to hold statistical information about connections that have been - * established using the HTTP/1.1 upgrade mechanism. Bytes sent/received will - * always be populated. Messages sent/received will be populated if that makes - * sense for the protocol and the information is exposed by the protocol - * implementation. + * Structure to hold statistical information about connections that have been established using the HTTP/1.1 upgrade + * mechanism. Bytes sent/received will always be populated. Messages sent/received will be populated if that makes sense + * for the protocol and the information is exposed by the protocol implementation. */ -public class UpgradeInfo { +public class UpgradeInfo { private UpgradeGroupInfo groupInfo = null; private volatile long bytesSent = 0; @@ -32,7 +30,6 @@ public class UpgradeInfo { private volatile long msgsReceived = 0; - public UpgradeGroupInfo getGlobalProcessor() { return groupInfo; } @@ -54,9 +51,11 @@ public class UpgradeInfo { public long getBytesSent() { return bytesSent; } + public void setBytesSent(long bytesSent) { this.bytesSent = bytesSent; } + public void addBytesSent(long bytesSent) { this.bytesSent += bytesSent; } @@ -65,9 +64,11 @@ public class UpgradeInfo { public long getBytesReceived() { return bytesReceived; } + public void setBytesReceived(long bytesReceived) { this.bytesReceived = bytesReceived; } + public void addBytesReceived(long bytesReceived) { this.bytesReceived += bytesReceived; } @@ -76,9 +77,11 @@ public class UpgradeInfo { public long getMsgsSent() { return msgsSent; } + public void setMsgsSent(long msgsSent) { this.msgsSent = msgsSent; } + public void addMsgsSent(long msgsSent) { this.msgsSent += msgsSent; } @@ -87,9 +90,11 @@ public class UpgradeInfo { public long getMsgsReceived() { return msgsReceived; } + public void setMsgsReceived(long msgsReceived) { this.msgsReceived = msgsReceived; } + public void addMsgsReceived(long msgsReceived) { this.msgsReceived += msgsReceived; } diff --git a/java/org/apache/coyote/http11/upgrade/UpgradeProcessorExternal.java b/java/org/apache/coyote/http11/upgrade/UpgradeProcessorExternal.java index 6b993add26..c08a6e3b33 100644 --- a/java/org/apache/coyote/http11/upgrade/UpgradeProcessorExternal.java +++ b/java/org/apache/coyote/http11/upgrade/UpgradeProcessorExternal.java @@ -117,8 +117,7 @@ public class UpgradeProcessorExternal extends UpgradeProcessorBase { } return SocketState.CLOSED; } - if (upgradeServletInputStream.isClosed() && - upgradeServletOutputStream.isClosed()) { + if (upgradeServletInputStream.isClosed() && upgradeServletOutputStream.isClosed()) { if (log.isTraceEnabled()) { log.trace(sm.getString("upgradeProcessor.requiredClose", Boolean.valueOf(upgradeServletInputStream.isClosed()), diff --git a/java/org/apache/coyote/http11/upgrade/UpgradeServletInputStream.java b/java/org/apache/coyote/http11/upgrade/UpgradeServletInputStream.java index 7e29a88671..948f568ac0 100644 --- a/java/org/apache/coyote/http11/upgrade/UpgradeServletInputStream.java +++ b/java/org/apache/coyote/http11/upgrade/UpgradeServletInputStream.java @@ -32,8 +32,7 @@ import org.apache.tomcat.util.res.StringManager; public class UpgradeServletInputStream extends ServletInputStream { private static final Log log = LogFactory.getLog(UpgradeServletInputStream.class); - private static final StringManager sm = - StringManager.getManager(UpgradeServletInputStream.class); + private static final StringManager sm = StringManager.getManager(UpgradeServletInputStream.class); private final UpgradeProcessorBase processor; private final SocketWrapperBase<?> socketWrapper; @@ -57,8 +56,7 @@ public class UpgradeServletInputStream extends ServletInputStream { @Override public final boolean isFinished() { if (listener == null) { - throw new IllegalStateException( - sm.getString("upgrade.sis.isFinished.ise")); + throw new IllegalStateException(sm.getString("upgrade.sis.isFinished.ise")); } return eof; } @@ -67,8 +65,7 @@ public class UpgradeServletInputStream extends ServletInputStream { @Override public final boolean isReady() { if (listener == null) { - throw new IllegalStateException( - sm.getString("upgrade.sis.isReady.ise")); + throw new IllegalStateException(sm.getString("upgrade.sis.isReady.ise")); } if (eof || closed) { @@ -92,12 +89,10 @@ public class UpgradeServletInputStream extends ServletInputStream { @Override public final void setReadListener(ReadListener listener) { if (listener == null) { - throw new IllegalArgumentException( - sm.getString("upgrade.sis.readListener.null")); + throw new IllegalArgumentException(sm.getString("upgrade.sis.readListener.null")); } if (this.listener != null) { - throw new IllegalArgumentException( - sm.getString("upgrade.sis.readListener.set")); + throw new IllegalArgumentException(sm.getString("upgrade.sis.readListener.set")); } if (closed) { throw new IllegalStateException(sm.getString("upgrade.sis.read.closed")); @@ -171,7 +166,6 @@ public class UpgradeServletInputStream extends ServletInputStream { } - @Override public void close() throws IOException { eof = true; diff --git a/java/org/apache/coyote/http11/upgrade/UpgradeServletOutputStream.java b/java/org/apache/coyote/http11/upgrade/UpgradeServletOutputStream.java index e857517e2b..c41aecf624 100644 --- a/java/org/apache/coyote/http11/upgrade/UpgradeServletOutputStream.java +++ b/java/org/apache/coyote/http11/upgrade/UpgradeServletOutputStream.java @@ -32,8 +32,7 @@ import org.apache.tomcat.util.res.StringManager; public class UpgradeServletOutputStream extends ServletOutputStream { private static final Log log = LogFactory.getLog(UpgradeServletOutputStream.class); - private static final StringManager sm = - StringManager.getManager(UpgradeServletOutputStream.class); + private static final StringManager sm = StringManager.getManager(UpgradeServletOutputStream.class); private final UpgradeProcessorBase processor; private final SocketWrapperBase<?> socketWrapper; @@ -61,7 +60,6 @@ public class UpgradeServletOutputStream extends ServletOutputStream { private boolean registered = false; - public UpgradeServletOutputStream(UpgradeProcessorBase processor, SocketWrapperBase<?> socketWrapper, UpgradeInfo upgradeInfo) { this.processor = processor; @@ -73,8 +71,7 @@ public class UpgradeServletOutputStream extends ServletOutputStream { @Override public final boolean isReady() { if (listener == null) { - throw new IllegalStateException( - sm.getString("upgrade.sos.canWrite.ise")); + throw new IllegalStateException(sm.getString("upgrade.sos.canWrite.ise")); } if (closed) { return false; @@ -88,7 +85,7 @@ public class UpgradeServletOutputStream extends ServletOutputStream { // for write and multiple registrations will cause problems. registered = true; return false; - } else if (registered){ + } else if (registered) { // The socket is already registered for write and multiple // registrations will cause problems. return false; @@ -104,12 +101,10 @@ public class UpgradeServletOutputStream extends ServletOutputStream { @Override public final void setWriteListener(WriteListener listener) { if (listener == null) { - throw new IllegalArgumentException( - sm.getString("upgrade.sos.writeListener.null")); + throw new IllegalArgumentException(sm.getString("upgrade.sos.writeListener.null")); } if (this.listener != null) { - throw new IllegalArgumentException( - sm.getString("upgrade.sos.writeListener.set")); + throw new IllegalArgumentException(sm.getString("upgrade.sos.writeListener.set")); } if (closed) { throw new IllegalStateException(sm.getString("upgrade.sos.write.closed")); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org