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/06/08 19:57:06 UTC
svn commit: r1684233 - in /tomcat/trunk: java/org/apache/coyote/http2/
test/org/apache/coyote/http2/
Author: markt
Date: Mon Jun 8 17:57:05 2015
New Revision: 1684233
URL: http://svn.apache.org/r1684233
Log:
Rename ErrorCode -> Error
Added:
tomcat/trunk/java/org/apache/coyote/http2/Error.java
- copied, changed from r1683410, tomcat/trunk/java/org/apache/coyote/http2/ErrorCode.java
Removed:
tomcat/trunk/java/org/apache/coyote/http2/ErrorCode.java
Modified:
tomcat/trunk/java/org/apache/coyote/http2/ConnectionSettings.java
tomcat/trunk/java/org/apache/coyote/http2/FrameType.java
tomcat/trunk/java/org/apache/coyote/http2/Http2Exception.java
tomcat/trunk/java/org/apache/coyote/http2/Http2Parser.java
tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java
tomcat/trunk/java/org/apache/coyote/http2/StreamStateMachine.java
tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_4_3.java
tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_1.java
Modified: tomcat/trunk/java/org/apache/coyote/http2/ConnectionSettings.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/ConnectionSettings.java?rev=1684233&r1=1684232&r2=1684233&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/ConnectionSettings.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/ConnectionSettings.java Mon Jun 8 17:57:05 2015
@@ -84,7 +84,7 @@ public class ConnectionSettings {
// Need to put a sensible limit on this. Start with 16k (default is 4k)
if (headerTableSize > (16 * 1024)) {
throw new Http2Exception(sm.getString("connectionSettings.headerTableSizeLimit",
- Long.toString(headerTableSize)), 0, ErrorCode.PROTOCOL_ERROR);
+ Long.toString(headerTableSize)), 0, Error.PROTOCOL_ERROR);
}
this.headerTableSize = (int) headerTableSize;
}
@@ -98,7 +98,7 @@ public class ConnectionSettings {
// will never be negative
if (enablePush > 1) {
throw new Http2Exception(sm.getString("connectionSettings.enablePushInvalid",
- Long.toString(enablePush)), 0, ErrorCode.PROTOCOL_ERROR);
+ Long.toString(enablePush)), 0, Error.PROTOCOL_ERROR);
}
this.enablePush = (enablePush == 1);
}
@@ -119,7 +119,7 @@ public class ConnectionSettings {
if (initialWindowSize > MAX_WINDOW_SIZE) {
throw new Http2Exception(sm.getString("connectionSettings.windowSizeTooBig",
Long.toString(initialWindowSize), Long.toString(MAX_WINDOW_SIZE)),
- 0, ErrorCode.PROTOCOL_ERROR);
+ 0, Error.PROTOCOL_ERROR);
}
this.initialWindowSize = (int) initialWindowSize;
}
@@ -132,7 +132,7 @@ public class ConnectionSettings {
if (maxFrameSize < MIN_MAX_FRAME_SIZE || maxFrameSize > MAX_MAX_FRAME_SIZE) {
throw new Http2Exception(sm.getString("connectionSettings.maxFrameSizeInvalid",
Long.toString(maxFrameSize), Integer.toString(MIN_MAX_FRAME_SIZE),
- Integer.toString(MAX_MAX_FRAME_SIZE)), 0, ErrorCode.PROTOCOL_ERROR);
+ Integer.toString(MAX_MAX_FRAME_SIZE)), 0, Error.PROTOCOL_ERROR);
}
this.maxFrameSize = (int) maxFrameSize;
}
Copied: tomcat/trunk/java/org/apache/coyote/http2/Error.java (from r1683410, tomcat/trunk/java/org/apache/coyote/http2/ErrorCode.java)
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/Error.java?p2=tomcat/trunk/java/org/apache/coyote/http2/Error.java&p1=tomcat/trunk/java/org/apache/coyote/http2/ErrorCode.java&r1=1683410&r2=1684233&rev=1684233&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/ErrorCode.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/Error.java Mon Jun 8 17:57:05 2015
@@ -16,7 +16,7 @@
*/
package org.apache.coyote.http2;
-public enum ErrorCode {
+public enum Error {
NO_ERROR (0x00),
PROTOCOL_ERROR (0x01),
@@ -33,21 +33,21 @@ public enum ErrorCode {
INADEQUATE_SECURITY (0x0c),
HTTP_1_1_REQUIRED (0x0d);
- private final long errorCode;
+ private final long code;
- private ErrorCode(long errorCode) {
- this.errorCode = errorCode;
+ private Error(long code) {
+ this.code = code;
}
- public long getErrorCode() {
- return errorCode;
+ public long getCode() {
+ return code;
}
- public byte[] getErrorCodeBytes() {
- byte[] errorCodeByte = new byte[4];
- ByteUtil.setFourBytes(errorCodeByte, 0, errorCode);
- return errorCodeByte;
+ public byte[] getCodeBytes() {
+ byte[] codeByte = new byte[4];
+ ByteUtil.setFourBytes(codeByte, 0, code);
+ return codeByte;
}
}
Modified: tomcat/trunk/java/org/apache/coyote/http2/FrameType.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/FrameType.java?rev=1684233&r1=1684232&r2=1684233&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/FrameType.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/FrameType.java Mon Jun 8 17:57:05 2015
@@ -59,10 +59,10 @@ public enum FrameType {
public void checkStream(String connectionId, int streamId) throws Http2Exception {
if (streamId == 0 && !streamZero) {
throw new Http2Exception(sm.getString("frameType.checkStream.invalidForZero",
- connectionId, this), 0, ErrorCode.PROTOCOL_ERROR);
+ connectionId, this), 0, Error.PROTOCOL_ERROR);
} else if (streamId != 0 && !streamNonZero) {
throw new Http2Exception(sm.getString("frameType.checkStream.invalidForNonZero",
- connectionId, Integer.valueOf(streamId), this), 0, ErrorCode.PROTOCOL_ERROR);
+ connectionId, Integer.valueOf(streamId), this), 0, Error.PROTOCOL_ERROR);
}
}
@@ -72,7 +72,7 @@ public enum FrameType {
if (payloadSizeValidator != null && !payloadSizeValidator.test(payloadSize)) {
throw new Http2Exception(sm.getString("frameType.checkPayloadSize",
connectionId, Integer.toString(streamId), this, Integer.toString(payloadSize)),
- 0, ErrorCode.FRAME_SIZE_ERROR);
+ 0, Error.FRAME_SIZE_ERROR);
}
}
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=1684233&r1=1684232&r2=1684233&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/Http2Exception.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/Http2Exception.java Mon Jun 8 17:57:05 2015
@@ -23,13 +23,13 @@ public class Http2Exception extends IOEx
private static final long serialVersionUID = 1L;
private final int streamId;
- private final ErrorCode errorCode;
+ private final Error error;
- public Http2Exception(String msg, int streamId, ErrorCode errorCode) {
+ public Http2Exception(String msg, int streamId, Error error) {
super(msg);
this.streamId = streamId;
- this.errorCode = errorCode;
+ this.error = error;
}
@@ -38,7 +38,7 @@ public class Http2Exception extends IOEx
}
- public ErrorCode getErrorCode() {
- return errorCode;
+ public Error getError() {
+ return error;
}
}
Modified: tomcat/trunk/java/org/apache/coyote/http2/Http2Parser.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/Http2Parser.java?rev=1684233&r1=1684232&r2=1684233&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/Http2Parser.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/Http2Parser.java Mon Jun 8 17:57:05 2015
@@ -233,7 +233,7 @@ class Http2Parser {
boolean ack = Flags.isAck(flags);
if (payloadSize > 0 && ack) {
throw new Http2Exception(sm.getString("http2Parser.processFrameSettings.ackWithNonZeroPayload"),
- 0, ErrorCode.FRAME_SIZE_ERROR);
+ 0, Error.FRAME_SIZE_ERROR);
}
if (payloadSize != 0) {
@@ -252,7 +252,7 @@ class Http2Parser {
private void readPushPromiseFrame(int streamId) throws IOException {
throw new Http2Exception(sm.getString("http2Parser.processFramePushPromise",
- connectionId, Integer.valueOf(streamId)), 0, ErrorCode.PROTOCOL_ERROR);
+ connectionId, Integer.valueOf(streamId)), 0, Error.PROTOCOL_ERROR);
}
@@ -295,7 +295,7 @@ class Http2Parser {
// Validate the data
if (windowSizeIncrement == 0) {
throw new Http2Exception("http2Parser.processFrameWindowUpdate.invalidIncrement",
- streamId, ErrorCode.PROTOCOL_ERROR);
+ streamId, Error.PROTOCOL_ERROR);
}
output.incrementWindowSize(streamId, windowSizeIncrement);
@@ -308,7 +308,7 @@ class Http2Parser {
// No headers to continue
throw new Http2Exception(sm.getString(
"http2Parser.processFrameContinuation.notExpected", connectionId,
- Integer.toString(streamId)), 0, ErrorCode.PROTOCOL_ERROR);
+ Integer.toString(streamId)), 0, Error.PROTOCOL_ERROR);
}
boolean endOfHeaders = Flags.isEndOfHeaders(flags);
@@ -337,7 +337,7 @@ class Http2Parser {
} catch (HpackException hpe) {
throw new Http2Exception(
sm.getString("http2Parser.processFrameHeaders.decodingFailed"),
- 0, ErrorCode.COMPRESSION_ERROR);
+ 0, Error.COMPRESSION_ERROR);
}
// switches to write mode
headerReadBuffer.compact();
@@ -347,7 +347,7 @@ class Http2Parser {
if (headerReadBuffer.position() > 0 && endOfHeaders) {
throw new Http2Exception(
sm.getString("http2Parser.processFrameHeaders.decodingDataLeft"),
- 0, ErrorCode.COMPRESSION_ERROR);
+ 0, Error.COMPRESSION_ERROR);
}
}
@@ -392,25 +392,25 @@ class Http2Parser {
if (expected != null && frameType != expected) {
throw new Http2Exception(sm.getString("http2Parser.processFrame.unexpectedType",
- expected, frameType), streamId, ErrorCode.PROTOCOL_ERROR);
+ expected, frameType), streamId, Error.PROTOCOL_ERROR);
}
if (payloadSize > maxPayloadSize) {
throw new Http2Exception(sm.getString("http2Parser.payloadTooBig",
Integer.toString(payloadSize), Integer.toString(maxPayloadSize)),
- streamId, ErrorCode.FRAME_SIZE_ERROR);
+ streamId, Error.FRAME_SIZE_ERROR);
}
if (headersCurrentStream != -1) {
if (headersCurrentStream != streamId) {
throw new Http2Exception(sm.getString("http2Parser.headers.wrongStream",
connectionId, Integer.toString(headersCurrentStream),
- Integer.toString(streamId)), streamId, ErrorCode.COMPRESSION_ERROR);
+ Integer.toString(streamId)), streamId, Error.COMPRESSION_ERROR);
}
if (frameType != FrameType.CONTINUATION) {
throw new Http2Exception(sm.getString("http2Parser.headers.wrongFrameType",
connectionId, Integer.toString(headersCurrentStream),
- frameType), streamId, ErrorCode.COMPRESSION_ERROR);
+ frameType), streamId, Error.COMPRESSION_ERROR);
}
}
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=1684233&r1=1684232&r2=1684233&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java Mon Jun 8 17:57:05 2015
@@ -344,7 +344,7 @@ public class Http2UpgradeHandler extends
byte[] fixedPayload = new byte[8];
// TODO needs to be correct value
ByteUtil.set31Bits(fixedPayload, 0, (2 << 31) - 1);
- ByteUtil.setFourBytes(fixedPayload, 4, h2e.getErrorCode().getErrorCode());
+ ByteUtil.setFourBytes(fixedPayload, 4, h2e.getError().getCode());
byte[] debugMessage = h2e.getMessage().getBytes(StandardCharsets.UTF_8);
byte[] payloadLength = new byte[3];
ByteUtil.setThreeBytes(payloadLength, 0, debugMessage.length + 8);
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=1684233&r1=1684232&r2=1684233&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/StreamStateMachine.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/StreamStateMachine.java Mon Jun 8 17:57:05 2015
@@ -126,29 +126,29 @@ public class StreamStateMachine {
private enum State {
- IDLE (true, ErrorCode.PROTOCOL_ERROR, FrameType.HEADERS, FrameType.PRIORITY),
- OPEN (true, ErrorCode.PROTOCOL_ERROR, FrameType.DATA, FrameType.HEADERS,
+ IDLE (true, Error.PROTOCOL_ERROR, FrameType.HEADERS, FrameType.PRIORITY),
+ OPEN (true, Error.PROTOCOL_ERROR, FrameType.DATA, FrameType.HEADERS,
FrameType.PRIORITY, FrameType.RST, FrameType.PUSH_PROMISE,
FrameType.WINDOW_UPDATE),
- RESERVED_LOCAL (true, ErrorCode.PROTOCOL_ERROR, FrameType.PRIORITY, FrameType.RST,
+ RESERVED_LOCAL (true, Error.PROTOCOL_ERROR, FrameType.PRIORITY, FrameType.RST,
FrameType.WINDOW_UPDATE),
- RESERVED_REMOTE (true, ErrorCode.PROTOCOL_ERROR, FrameType.HEADERS, FrameType.PRIORITY,
+ RESERVED_REMOTE (true, Error.PROTOCOL_ERROR, FrameType.HEADERS, FrameType.PRIORITY,
FrameType.RST),
- HALF_CLOSED_LOCAL (true, ErrorCode.PROTOCOL_ERROR, FrameType.DATA, FrameType.HEADERS,
+ HALF_CLOSED_LOCAL (true, Error.PROTOCOL_ERROR, FrameType.DATA, FrameType.HEADERS,
FrameType.PRIORITY, FrameType.RST, FrameType.PUSH_PROMISE,
FrameType.WINDOW_UPDATE),
- HALF_CLOSED_REMOTE (true, ErrorCode.STREAM_CLOSED, FrameType.PRIORITY, FrameType.RST,
+ HALF_CLOSED_REMOTE (true, Error.STREAM_CLOSED, FrameType.PRIORITY, FrameType.RST,
FrameType.WINDOW_UPDATE),
- CLOSED_RX (true, ErrorCode.STREAM_CLOSED, FrameType.PRIORITY),
- CLOSED_RST (false, ErrorCode.STREAM_CLOSED, FrameType.PRIORITY),
- CLOSED_TX (true, ErrorCode.STREAM_CLOSED, FrameType.PRIORITY, FrameType.RST,
+ CLOSED_RX (true, Error.STREAM_CLOSED, FrameType.PRIORITY),
+ CLOSED_RST (false, Error.STREAM_CLOSED, FrameType.PRIORITY),
+ CLOSED_TX (true, Error.STREAM_CLOSED, FrameType.PRIORITY, FrameType.RST,
FrameType.WINDOW_UPDATE);
private final boolean connectionErrorForInvalidFrame;
- private final ErrorCode errorCodeForInvalidFrame;
+ private final Error errorCodeForInvalidFrame;
private final Set<FrameType> frameTypesPermitted = new HashSet<>();
- private State(boolean connectionErrorForInvalidFrame, ErrorCode errorCode,
+ private State(boolean connectionErrorForInvalidFrame, Error errorCode,
FrameType... frameTypes) {
this.connectionErrorForInvalidFrame = connectionErrorForInvalidFrame;
this.errorCodeForInvalidFrame = errorCode;
Modified: tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_4_3.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_4_3.java?rev=1684233&r1=1684232&r2=1684233&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_4_3.java (original)
+++ tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_4_3.java Mon Jun 8 17:57:05 2015
@@ -53,7 +53,7 @@ public class TestHttp2Section_4_3 extend
Assert.assertTrue(output.getTrace(),
output.getTrace().startsWith("0-Goaway-[2147483647]-[" +
- ErrorCode.COMPRESSION_ERROR.getErrorCode() + "]-["));
+ Error.COMPRESSION_ERROR.getCode() + "]-["));
}
@@ -108,6 +108,6 @@ public class TestHttp2Section_4_3 extend
Assert.assertTrue(output.getTrace(),
output.getTrace().startsWith("0-Goaway-[2147483647]-[" +
- ErrorCode.COMPRESSION_ERROR.getErrorCode() + "]-["));
+ Error.COMPRESSION_ERROR.getCode() + "]-["));
}
}
Modified: tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_1.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_1.java?rev=1684233&r1=1684232&r2=1684233&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_1.java (original)
+++ tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_1.java Mon Jun 8 17:57:05 2015
@@ -41,7 +41,7 @@ public class TestHttp2Section_5_1 extend
Assert.assertTrue(output.getTrace(),
output.getTrace().startsWith("0-Goaway-[2147483647]-[" +
- ErrorCode.PROTOCOL_ERROR.getErrorCode() + "]-["));
+ Error.PROTOCOL_ERROR.getCode() + "]-["));
}
@@ -55,7 +55,7 @@ public class TestHttp2Section_5_1 extend
Assert.assertTrue(output.getTrace(),
output.getTrace().startsWith("0-Goaway-[2147483647]-[" +
- ErrorCode.PROTOCOL_ERROR.getErrorCode() + "]-["));
+ Error.PROTOCOL_ERROR.getCode() + "]-["));
}
@@ -80,7 +80,7 @@ public class TestHttp2Section_5_1 extend
Assert.assertTrue(output.getTrace(),
output.getTrace().startsWith("0-Goaway-[2147483647]-[" +
- ErrorCode.STREAM_CLOSED.getErrorCode() + "]-["));
+ Error.STREAM_CLOSED.getCode() + "]-["));
}
@@ -104,7 +104,7 @@ public class TestHttp2Section_5_1 extend
writeFrame(frameHeader, headersPayload);
// Send a rst
- sendRst(3, ErrorCode.INTERNAL_ERROR.getErrorCode());
+ sendRst(3, Error.INTERNAL_ERROR.getCode());
// Then try sending some data (which should fail)
sendData(3, new byte[] {});
@@ -112,7 +112,7 @@ public class TestHttp2Section_5_1 extend
Assert.assertTrue(output.getTrace(),
output.getTrace().startsWith("0-Goaway-[2147483647]-[" +
- ErrorCode.STREAM_CLOSED.getErrorCode() + "]-["));
+ Error.STREAM_CLOSED.getCode() + "]-["));
}
@@ -126,7 +126,7 @@ public class TestHttp2Section_5_1 extend
Assert.assertTrue(output.getTrace(),
output.getTrace().startsWith("0-Goaway-[2147483647]-[" +
- ErrorCode.STREAM_CLOSED.getErrorCode() + "]-["));
+ Error.STREAM_CLOSED.getCode() + "]-["));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r1684233 - in /tomcat/trunk: java/org/apache/coyote/http2/
test/org/apache/coyote/http2/
Posted by Mark Thomas <ma...@apache.org>.
On 09/06/2015 09:46, Konstantin Kolinko wrote:
> 2015-06-08 20:57 GMT+03:00 <ma...@apache.org>:
>> Author: markt
>> Date: Mon Jun 8 17:57:05 2015
>> New Revision: 1684233
>>
>> URL: http://svn.apache.org/r1684233
>> Log:
>> Rename ErrorCode -> Error
>>
>> Added:
>> tomcat/trunk/java/org/apache/coyote/http2/Error.java
>> - copied, changed from r1683410, tomcat/trunk/java/org/apache/coyote/http2/ErrorCode.java
>
>
> This name collides with java.lang.Error class.
>
> It is unlikely that you will use both in the same file, and accessing
> an enum value is visually different from a java class, but
> nevertheless I do not like this naming.
Fair enough. I'll rethink.
>> StreamError.java
>> ConnectionError.java
>
> Those are not instances of java.lang.Error, but ones of java.lang.Exception.
Indeed. But they align with things that the HTTP/2 spec calls connection
error and stream error. There are cases for both leaving the names as is
and for changing them to StreamException / ConnectionException. I'll
think it over while I look at a few other things.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r1684233 - in /tomcat/trunk: java/org/apache/coyote/http2/
test/org/apache/coyote/http2/
Posted by Konstantin Kolinko <kn...@gmail.com>.
2015-06-08 20:57 GMT+03:00 <ma...@apache.org>:
> Author: markt
> Date: Mon Jun 8 17:57:05 2015
> New Revision: 1684233
>
> URL: http://svn.apache.org/r1684233
> Log:
> Rename ErrorCode -> Error
>
> Added:
> tomcat/trunk/java/org/apache/coyote/http2/Error.java
> - copied, changed from r1683410, tomcat/trunk/java/org/apache/coyote/http2/ErrorCode.java
This name collides with java.lang.Error class.
It is unlikely that you will use both in the same file, and accessing
an enum value is visually different from a java class, but
nevertheless I do not like this naming.
> StreamError.java
> ConnectionError.java
Those are not instances of java.lang.Error, but ones of java.lang.Exception.
Best regards,
Konstantin Kolinko
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org