Author: markt Date: Fri Oct 7 20:32:49 2016 New Revision: 1763833 URL: http://svn.apache.org/viewvc?rev=1763833&view=rev Log: UCdetector - reduce visibility - add final - remove unused code
Modified: tomcat/trunk/java/org/apache/coyote/http2/AbstractStream.java tomcat/trunk/java/org/apache/coyote/http2/ConnectionException.java tomcat/trunk/java/org/apache/coyote/http2/HpackException.java tomcat/trunk/java/org/apache/coyote/http2/Http2Exception.java tomcat/trunk/java/org/apache/coyote/http2/Stream.java tomcat/trunk/java/org/apache/coyote/http2/StreamException.java Modified: tomcat/trunk/java/org/apache/coyote/http2/AbstractStream.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/AbstractStream.java?rev=1763833&r1=1763832&r2=1763833&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http2/AbstractStream.java (original) +++ tomcat/trunk/java/org/apache/coyote/http2/AbstractStream.java Fri Oct 7 20:32:49 2016 @@ -37,17 +37,17 @@ abstract class AbstractStream { private final Set<AbstractStream> childStreams = new HashSet<>(); private long windowSize = ConnectionSettingsBase.DEFAULT_INITIAL_WINDOW_SIZE; - public Integer getIdentifier() { + final Integer getIdentifier() { return identifier; } - public AbstractStream(Integer identifier) { + AbstractStream(Integer identifier) { this.identifier = identifier; } - void detachFromParent() { + final void detachFromParent() { if (parentStream != null) { parentStream.getChildStreams().remove(this); parentStream = null; @@ -55,18 +55,13 @@ abstract class AbstractStream { } - void addChild(AbstractStream child) { - child.setParent(this); + final void addChild(AbstractStream child) { + child.setParentStream(this); childStreams.add(child); } - private void setParent(AbstractStream parent) { - this.parentStream = parent; - } - - - boolean isDescendant(AbstractStream stream) { + final boolean isDescendant(AbstractStream stream) { if (childStreams.contains(stream)) { return true; } @@ -79,38 +74,38 @@ abstract class AbstractStream { } - AbstractStream getParentStream() { + final AbstractStream getParentStream() { return parentStream; } - void setParentStream(AbstractStream parentStream) { + final void setParentStream(AbstractStream parentStream) { this.parentStream = parentStream; } - Set<AbstractStream> getChildStreams() { + final Set<AbstractStream> getChildStreams() { return childStreams; } - protected synchronized void setWindowSize(long windowSize) { + final synchronized void setWindowSize(long windowSize) { this.windowSize = windowSize; } - protected synchronized long getWindowSize() { + final synchronized long getWindowSize() { return windowSize; } /** * Increment window size. - * @param increment The amount of the incrementation + * @param increment The amount by which the window size should be increased * @throws Http2Exception If the window size is now higher than * the maximum allowed */ - protected synchronized void incrementWindowSize(int increment) throws Http2Exception { + synchronized void incrementWindowSize(int increment) throws Http2Exception { // No need for overflow protection here. // Increment can't be more than Integer.MAX_VALUE and once windowSize // goes beyond 2^31-1 an error is triggered. @@ -134,7 +129,7 @@ abstract class AbstractStream { } - protected synchronized void decrementWindowSize(int decrement) { + final synchronized void decrementWindowSize(int decrement) { // No need for overflow protection here. Decrement can never be larger // the Integer.MAX_VALUE and once windowSize goes negative no further // decrements are permitted @@ -146,7 +141,7 @@ abstract class AbstractStream { } - protected abstract String getConnectionId(); + abstract String getConnectionId(); - protected abstract int getWeight(); + abstract int getWeight(); } Modified: tomcat/trunk/java/org/apache/coyote/http2/ConnectionException.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/ConnectionException.java?rev=1763833&r1=1763832&r2=1763833&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http2/ConnectionException.java (original) +++ tomcat/trunk/java/org/apache/coyote/http2/ConnectionException.java Fri Oct 7 20:32:49 2016 @@ -19,11 +19,11 @@ package org.apache.coyote.http2; /** * Thrown when an HTTP/2 connection error occurs. */ -public class ConnectionException extends Http2Exception { +class ConnectionException extends Http2Exception { private static final long serialVersionUID = 1L; - public ConnectionException(String msg, Http2Error error) { + ConnectionException(String msg, Http2Error error) { super(msg, error); } } Modified: tomcat/trunk/java/org/apache/coyote/http2/HpackException.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/HpackException.java?rev=1763833&r1=1763832&r2=1763833&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http2/HpackException.java (original) +++ tomcat/trunk/java/org/apache/coyote/http2/HpackException.java Fri Oct 7 20:32:49 2016 @@ -20,17 +20,14 @@ package org.apache.coyote.http2; * Exception that is thrown when the HPACK compress context is broken. In this * case the connection must be closed. */ -public class HpackException extends Exception { +class HpackException extends Exception { private static final long serialVersionUID = 1L; - public HpackException(String message, Throwable cause) { - super(message, cause); - } - public HpackException(String message) { + HpackException(String message) { super(message); } - public HpackException() { + HpackException() { super(); } } Modified: tomcat/trunk/java/org/apache/coyote/http2/Http2Exception.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/Http2Exception.java?rev=1763833&r1=1763832&r2=1763833&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http2/Http2Exception.java (original) +++ tomcat/trunk/java/org/apache/coyote/http2/Http2Exception.java Fri Oct 7 20:32:49 2016 @@ -16,20 +16,20 @@ */ package org.apache.coyote.http2; -public abstract class Http2Exception extends Exception { +abstract class Http2Exception extends Exception { private static final long serialVersionUID = 1L; private final Http2Error error; - public Http2Exception(String msg, Http2Error error) { + Http2Exception(String msg, Http2Error error) { super(msg); this.error = error; } - public Http2Error getError() { + Http2Error getError() { return error; } } Modified: tomcat/trunk/java/org/apache/coyote/http2/Stream.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/Stream.java?rev=1763833&r1=1763832&r2=1763833&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http2/Stream.java (original) +++ tomcat/trunk/java/org/apache/coyote/http2/Stream.java Fri Oct 7 20:32:49 2016 @@ -35,7 +35,7 @@ import org.apache.tomcat.util.buf.ByteCh import org.apache.tomcat.util.net.ApplicationBufferHandler; import org.apache.tomcat.util.res.StringManager; -public class Stream extends AbstractStream implements HeaderEmitter { +class Stream extends AbstractStream implements HeaderEmitter { private static final Log log = LogFactory.getLog(Stream.class); private static final StringManager sm = StringManager.getManager(Stream.class); @@ -57,12 +57,12 @@ public class Stream extends AbstractStre private final StreamOutputBuffer outputBuffer = new StreamOutputBuffer(); - public Stream(Integer identifier, Http2UpgradeHandler handler) { + Stream(Integer identifier, Http2UpgradeHandler handler) { this(identifier, handler, null); } - public Stream(Integer identifier, Http2UpgradeHandler handler, Request coyoteRequest) { + Stream(Integer identifier, Http2UpgradeHandler handler, Request coyoteRequest) { super(identifier); this.handler = handler; setParentStream(handler); @@ -90,7 +90,7 @@ public class Stream extends AbstractStre } - void rePrioritise(AbstractStream parent, boolean exclusive, int weight) { + final void rePrioritise(AbstractStream parent, boolean exclusive, int weight) { if (log.isDebugEnabled()) { log.debug(sm.getString("stream.reprioritisation.debug", getConnectionId(), getIdentifier(), Boolean.toString(exclusive), @@ -118,7 +118,7 @@ public class Stream extends AbstractStre } - void receiveReset(long errorCode) { + final void receiveReset(long errorCode) { if (log.isDebugEnabled()) { log.debug(sm.getString("stream.reset.debug", getConnectionId(), getIdentifier(), Long.toString(errorCode))); @@ -136,13 +136,13 @@ public class Stream extends AbstractStre } - void checkState(FrameType frameType) throws Http2Exception { + final void checkState(FrameType frameType) throws Http2Exception { state.checkFrameType(frameType); } @Override - protected synchronized void incrementWindowSize(int windowSizeIncrement) throws Http2Exception { + final synchronized void incrementWindowSize(int windowSizeIncrement) throws Http2Exception { // If this is zero then any thread that has been trying to write for // this stream will be waiting. Notify that thread it can continue. Use // notify all even though only one thread is waiting to be on the safe @@ -155,7 +155,8 @@ public class Stream extends AbstractStre } - private synchronized int reserveWindowSize(int reservation, boolean block) throws IOException { + private final synchronized int reserveWindowSize(int reservation, boolean block) + throws IOException { long windowSize = getWindowSize(); while (windowSize < 1) { if (!canWrite()) { @@ -188,7 +189,7 @@ public class Stream extends AbstractStre @Override - public void emitHeader(String name, String value, boolean neverIndex) { + public final void emitHeader(String name, String value, boolean neverIndex) { if (log.isDebugEnabled()) { log.debug(sm.getString("stream.header.debug", getConnectionId(), getIdentifier(), name, value)); @@ -238,19 +239,18 @@ public class Stream extends AbstractStre } - void writeHeaders() throws IOException { + final void writeHeaders() throws IOException { // TODO: Is 1k the optimal value? handler.writeHeaders(this, coyoteResponse, 1024); } - void writeAck() throws IOException { + final void writeAck() throws IOException { // TODO: Is 64 too big? Just the status header with compression handler.writeHeaders(this, ACK_RESPONSE, 64); } - - void flushData() throws IOException { + final void flushData() throws IOException { if (log.isDebugEnabled()) { log.debug(sm.getString("stream.write", getConnectionId(), getIdentifier())); } @@ -259,89 +259,89 @@ public class Stream extends AbstractStre @Override - protected final String getConnectionId() { + final String getConnectionId() { return getParentStream().getConnectionId(); } @Override - protected int getWeight() { + final int getWeight() { return weight; } - Request getCoyoteRequest() { + final Request getCoyoteRequest() { return coyoteRequest; } - Response getCoyoteResponse() { + final Response getCoyoteResponse() { return coyoteResponse; } - ByteBuffer getInputByteBuffer() { + final ByteBuffer getInputByteBuffer() { return inputBuffer.getInBuffer(); } - void receivedStartOfHeaders() { + final void receivedStartOfHeaders() { state.receivedStartOfHeaders(); } - void receivedEndOfStream() { + final void receivedEndOfStream() { state.recievedEndOfStream(); } - void sentEndOfStream() { + final void sentEndOfStream() { outputBuffer.endOfStreamSent = true; state.sentEndOfStream(); } - StreamInputBuffer getInputBuffer() { + final StreamInputBuffer getInputBuffer() { return inputBuffer; } - StreamOutputBuffer getOutputBuffer() { + final StreamOutputBuffer getOutputBuffer() { return outputBuffer; } - void sentPushPromise() { + final void sentPushPromise() { state.sentPushPromise(); } - boolean isActive() { + final boolean isActive() { return state.isActive(); } - boolean canWrite() { + final boolean canWrite() { return state.canWrite(); } - boolean isClosedFinal() { + final boolean isClosedFinal() { return state.isClosedFinal(); } - void closeIfIdle() { + final void closeIfIdle() { state.closeIfIdle(); } - boolean isInputFinished() { + private final boolean isInputFinished() { return !state.isFrameTypePermitted(FrameType.DATA); } - void close(Http2Exception http2Exception) { + final void close(Http2Exception http2Exception) { if (http2Exception instanceof StreamException) { try { StreamException se = (StreamException) http2Exception; @@ -359,12 +359,12 @@ public class Stream extends AbstractStre } - boolean isPushSupported() { + final boolean isPushSupported() { return handler.getRemoteSettings().getEnablePush(); } - boolean push(Request request) throws IOException { + final boolean push(Request request) throws IOException { if (!isPushSupported()) { return false; } @@ -394,8 +394,8 @@ public class Stream extends AbstractStre } - private static void push(final Http2UpgradeHandler handler, final Request request, final Stream stream) - throws IOException { + private static void push(final Http2UpgradeHandler handler, final Request request, + final Stream stream) throws IOException { if (org.apache.coyote.Constants.IS_SECURITY_ENABLED) { try { AccessController.doPrivileged( @@ -433,7 +433,7 @@ public class Stream extends AbstractStre */ @Override - public synchronized int doWrite(ByteBuffer chunk) throws IOException { + public final synchronized int doWrite(ByteBuffer chunk) throws IOException { if (closed) { throw new IllegalStateException( sm.getString("stream.closed", getConnectionId(), getIdentifier())); @@ -461,11 +461,11 @@ public class Stream extends AbstractStre return offset; } - public synchronized boolean flush(boolean block) throws IOException { + final synchronized boolean flush(boolean block) throws IOException { return flush(false, block); } - private synchronized boolean flush(boolean writeInProgress, boolean block) + private final synchronized boolean flush(boolean writeInProgress, boolean block) throws IOException { if (log.isDebugEnabled()) { log.debug(sm.getString("stream.outputBuffer.flush.debug", getConnectionId(), @@ -504,7 +504,7 @@ public class Stream extends AbstractStre return false; } - synchronized boolean isReady() { + final synchronized boolean isReady() { if (getWindowSize() > 0 && handler.getWindowSize() > 0) { return true; } else { @@ -513,24 +513,20 @@ public class Stream extends AbstractStre } @Override - public long getBytesWritten() { + public final long getBytesWritten() { return written; } - public void close() throws IOException { + final void close() throws IOException { closed = true; flushData(); } - public boolean isClosed() { - return closed; - } - /** * @return <code>true</code> if it is certain that the associated * response has no body. */ - public boolean hasNoBody() { + final boolean hasNoBody() { return ((written == 0) && closed); } } @@ -566,7 +562,8 @@ public class Stream extends AbstractStre private boolean reset = false; @Override - public int doRead(ApplicationBufferHandler applicationBufferHandler) throws IOException { + public final int doRead(ApplicationBufferHandler applicationBufferHandler) + throws IOException { ensureBuffersExist(); @@ -622,19 +619,19 @@ public class Stream extends AbstractStre } - void registerReadInterest() { + final void registerReadInterest() { synchronized (inBuffer) { readInterest = true; } } - synchronized boolean isRequestBodyFullyRead() { + final synchronized boolean isRequestBodyFullyRead() { return (inBuffer == null || inBuffer.position() == 0) && isInputFinished(); } - synchronized int available() { + final synchronized int available() { if (inBuffer == null) { return 0; } @@ -645,7 +642,7 @@ public class Stream extends AbstractStre /* * Called after placing some data in the inBuffer. */ - synchronized boolean onDataAvailable() { + final synchronized boolean onDataAvailable() { if (readInterest) { if (log.isDebugEnabled()) { log.debug(sm.getString("stream.inputBuffer.dispatch")); @@ -669,18 +666,18 @@ public class Stream extends AbstractStre } - public ByteBuffer getInBuffer() { + private final ByteBuffer getInBuffer() { ensureBuffersExist(); return inBuffer; } - protected synchronized void insertReplayedBody(ByteChunk body) { + final synchronized void insertReplayedBody(ByteChunk body) { inBuffer = ByteBuffer.wrap(body.getBytes(), body.getOffset(), body.getLength()); } - private void ensureBuffersExist() { + private final void ensureBuffersExist() { if (inBuffer == null) { // The client must obey Tomcat's window size when sending so // this is the initial window size set by Tomcat that the client @@ -696,7 +693,7 @@ public class Stream extends AbstractStre } - protected void receiveReset() { + private final void receiveReset() { if (inBuffer != null) { synchronized (inBuffer) { reset = true; Modified: tomcat/trunk/java/org/apache/coyote/http2/StreamException.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/StreamException.java?rev=1763833&r1=1763832&r2=1763833&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http2/StreamException.java (original) +++ tomcat/trunk/java/org/apache/coyote/http2/StreamException.java Fri Oct 7 20:32:49 2016 @@ -19,19 +19,19 @@ package org.apache.coyote.http2; /** * Thrown when an HTTP/2 stream error occurs. */ -public class StreamException extends Http2Exception { +class StreamException extends Http2Exception { private static final long serialVersionUID = 1L; private final int streamId; - public StreamException(String msg, Http2Error error, int streamId) { + StreamException(String msg, Http2Error error, int streamId) { super(msg, error); this.streamId = streamId; } - public int getStreamId() { + int getStreamId() { return streamId; } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org