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 2015/10/14 12:42:45 UTC
svn commit: r1708580 - in /tomcat/trunk/java/org/apache/coyote/http2:
Http2UpgradeHandler.java Stream.java StreamStateMachine.java
Author: markt
Date: Wed Oct 14 10:42:44 2015
New Revision: 1708580
URL: http://svn.apache.org/viewvc?rev=1708580&view=rev
Log:
Partially revert previous error handling changes. Generally, the reset always needs to be sent (even if the state doesn't change).
Modified:
tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java
tomcat/trunk/java/org/apache/coyote/http2/Stream.java
tomcat/trunk/java/org/apache/coyote/http2/StreamStateMachine.java
Modified: tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java?rev=1708580&r1=1708579&r2=1708580&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java Wed Oct 14 10:42:44 2015
@@ -401,35 +401,28 @@ public class Http2UpgradeHandler extends
}
- void resetStream(StreamException se) throws ConnectionException, IOException {
+ void resetStream(StreamException se) throws IOException {
if (log.isDebugEnabled()) {
log.debug(sm.getString("upgradeHandler.rst.debug", connectionId,
Integer.toString(se.getStreamId()), se.getError()));
}
- // If the stream is null, the server knows nothing about it. The ID can
- // only have come from the client so always send a reset.
- // If the stream is not null, the server does know about the stream so
- // only send the reset if the stream is in an appropriate state.
- Stream stream = getStream(se.getStreamId(), false);
- if (stream == null || stream.sendReset()) {
- // Write a RST frame
- byte[] rstFrame = new byte[13];
- // Length
- ByteUtil.setThreeBytes(rstFrame, 0, 4);
- // Type
- rstFrame[3] = FrameType.RST.getIdByte();
- // No flags
- // Stream ID
- ByteUtil.set31Bits(rstFrame, 5, se.getStreamId());
- // Payload
- ByteUtil.setFourBytes(rstFrame, 9, se.getError().getCode());
-
- synchronized (socketWrapper) {
- socketWrapper.write(true, rstFrame, 0, rstFrame.length);
- socketWrapper.flush(true);
- }
+ // Write a RST frame
+ byte[] rstFrame = new byte[13];
+ // Length
+ ByteUtil.setThreeBytes(rstFrame, 0, 4);
+ // Type
+ rstFrame[3] = FrameType.RST.getIdByte();
+ // No flags
+ // Stream ID
+ ByteUtil.set31Bits(rstFrame, 5, se.getStreamId());
+ // Payload
+ ByteUtil.setFourBytes(rstFrame, 9, se.getError().getCode());
+
+ synchronized (socketWrapper) {
+ socketWrapper.write(true, rstFrame, 0, rstFrame.length);
+ socketWrapper.flush(true);
}
}
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=1708580&r1=1708579&r2=1708580&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/Stream.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/Stream.java Wed Oct 14 10:42:44 2015
@@ -321,14 +321,11 @@ public class Stream extends AbstractStre
* <li>The stream is already reset</li>
* <li>The stream is already closed</li>
*
- * @return <code>true</code> if a reset frame needs to be sent to the peer,
- * otherwise <code>false</code>
- *
* @throws IllegalStateException If the stream is in a state that does not
* permit resets
*/
- boolean sendReset() {
- return state.sendReset();
+ void sendReset() {
+ state.sendReset();
}
@@ -356,8 +353,6 @@ public class Stream extends AbstractStre
if (http2Exception instanceof StreamException) {
try {
handler.resetStream((StreamException) http2Exception);
- } catch (ConnectionException ce) {
- handler.closeConnection(ce);
} catch (IOException ioe) {
// TODO i18n
ConnectionException ce = new ConnectionException("", Http2Error.PROTOCOL_ERROR);
Modified: tomcat/trunk/java/org/apache/coyote/http2/StreamStateMachine.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/StreamStateMachine.java?rev=1708580&r1=1708579&r2=1708580&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/StreamStateMachine.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/StreamStateMachine.java Wed Oct 14 10:42:44 2015
@@ -90,22 +90,16 @@ public class StreamStateMachine {
* <li>The stream is already closed</li>
* </ul>
*
- * @return <code>true</code> if a reset frame needs to be sent to the peer,
- * otherwise <code>false</code>
- *
* @throws IllegalStateException If the stream is in a state that does not
* permit resets
*/
- public synchronized boolean sendReset() {
+ public synchronized void sendReset() {
if (state == State.IDLE) {
throw new IllegalStateException(sm.getString("streamStateMachine.debug.change",
stream.getConnectionId(), stream.getIdentifier(), state));
}
if (state.canReset()) {
stateChange(state, State.CLOSED_RST_TX);
- return true;
- } else {
- return false;
}
}
@@ -217,7 +211,7 @@ public class StreamStateMachine {
FrameType.RST,
FrameType.PUSH_PROMISE,
FrameType.WINDOW_UPDATE),
- CLOSED_FINAL (false, false, false, false,
+ CLOSED_FINAL (false, false, false, true,
Http2Error.PROTOCOL_ERROR, FrameType.PRIORITY);
private final boolean canRead;
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org