Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ public static class Builder {
}

public Builder setHeaderTableSize(final int headerTableSize) {
Args.notNegative(headerTableSize, "Header table size");
this.headerTableSize = headerTableSize;
return this;
}
Expand All @@ -179,7 +178,7 @@ public Builder setPushEnabled(final boolean pushEnabled) {
}

public Builder setMaxConcurrentStreams(final int maxConcurrentStreams) {
this.maxConcurrentStreams = Args.checkRange(maxConcurrentStreams, 0, Integer.MAX_VALUE, "Max concurrent streams");
this.maxConcurrentStreams = maxConcurrentStreams;
return this;
}

Expand All @@ -195,7 +194,7 @@ public Builder setMaxFrameSize(final int maxFrameSize) {
}

public Builder setMaxHeaderListSize(final int maxHeaderListSize) {
this.maxHeaderListSize = Args.checkRange(maxHeaderListSize, 0, Integer.MAX_VALUE, "Max header list size");
this.maxHeaderListSize = maxHeaderListSize;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ public final void onOutput() throws HttpException, IOException {
})));
return;
}
while (streams.getLocalCount() < remoteConfig.getMaxConcurrentStreams()) {
while (streams.getLocalCount() < Integer.toUnsignedLong(remoteConfig.getMaxConcurrentStreams())) {
final Command command = ioSession.poll();
if (command == null) {
break;
Expand Down Expand Up @@ -1289,7 +1289,7 @@ private void consumeSettingsFrame(final ByteBuffer payload) throws IOException {
case INITIAL_WINDOW_SIZE:
if (value < 0) {
throw new H2ConnectionException(H2Error.FLOW_CONTROL_ERROR,
"Invalid initial window size: " + (value & 0xffffffffL));
"Invalid initial window size: " + Integer.toUnsignedLong(value));
}
try {
configBuilder.setInitialWindowSize(value);
Expand Down Expand Up @@ -1319,7 +1319,6 @@ private void consumeSettingsFrame(final ByteBuffer payload) throws IOException {
}
applyRemoteSettings(configBuilder.build());
}

private void produceOutput() throws HttpException, IOException {
for (final Iterator<H2Stream> it = streams.iterator(); it.hasNext(); ) {
final H2Stream stream = it.next();
Expand All @@ -1341,13 +1340,13 @@ private void produceOutput() throws HttpException, IOException {

private void applyRemoteSettings(final H2Config config) throws H2ConnectionException {
remoteConfig = config;

// The peer's HEADER_TABLE_SIZE is an upper bound for the encoder. Keep the local
// dynamic table bounded to limit memory usage and lookup cost per connection.
hPackEncoder.setMaxTableSize(Math.min(remoteConfig.getHeaderTableSize(), H2Config.INIT.getHeaderTableSize()));
hPackEncoder.setMaxTableSize((int) Math.min(
Integer.toUnsignedLong(remoteConfig.getHeaderTableSize()),
H2Config.INIT.getHeaderTableSize()));
final int delta = remoteConfig.getInitialWindowSize() - initOutputWinSize;
initOutputWinSize = remoteConfig.getInitialWindowSize();

final int maxFrameSize = remoteConfig.getMaxFrameSize();
if (maxFrameSize < outputBuffer.getMaxFramePayloadSize()) {
try {
Expand All @@ -1356,7 +1355,6 @@ private void applyRemoteSettings(final H2Config config) throws H2ConnectionExcep
throw new H2ConnectionException(H2Error.INTERNAL_ERROR, "Failure resizing the frame output buffer");
}
}

if (delta != 0) {
if (!streams.isEmpty()) {
for (final Iterator<H2Stream> it = streams.iterator(); it.hasNext(); ) {
Expand All @@ -1370,7 +1368,6 @@ private void applyRemoteSettings(final H2Config config) throws H2ConnectionExcep
}
}
}

private void applyLocalSettings() throws H2ConnectionException {
hPackDecoder.setMaxTableSize(localConfig.getHeaderTableSize());
hPackDecoder.setMaxListSize(localConfig.getMaxHeaderListSize());
Expand Down
Loading
Loading