Skip to content

Commit

Permalink
Fix incorrect name of decoderEnforceMaxRstFramesPerWindow property (#…
Browse files Browse the repository at this point in the history
…2740)

Motivation:

#2728 introduces 2 properties to control Netty
`decoderEnforceMaxRstFramesPerWindow` settings:
`-Dio.servicetalk.http.netty.http2.decoderEnforceMaxRstFramesPerWindow.maxConsecutiveEmptyFrames=200`
`-Dio.servicetalk.http.netty.http2.decoderEnforceMaxRstFramesPerWindow.secondsPerWindow=30`

The first property was named incorrectly, it must be
`maxRstFramesPerWindow`.

Modifications:
- Add a new property:
`-Dio.servicetalk.http.netty.http2.decoderEnforceMaxRstFramesPerWindow.maxRstFramesPerWindow=200`;
- Use previous `maxConsecutiveEmptyFrames` value as a fallback for
backward compatibility;

Result:

Properties names are consistent with their names in Netty.
  • Loading branch information
idelpivnitskiy committed Oct 30, 2023
1 parent 5e711b4 commit 231ec64
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright © 2021-2022 Apple Inc. and the ServiceTalk project authors
* Copyright © 2021-2023 Apple Inc. and the ServiceTalk project authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -44,11 +44,15 @@ final class OptimizedHttp2FrameCodecBuilder extends Http2FrameCodecBuilder {
// Netty. For the next major release we should either remove these properties or promote them to public API.
private static final String MAX_CONSECUTIVE_EMPTY_FRAMES_PROPERTY_NAME =
"io.servicetalk.http.netty.http2.decoderEnforceMaxRstFramesPerWindow.maxConsecutiveEmptyFrames";
private static final String MAX_RST_FRAMES_PER_WINDOW_PROPERTY_NAME =
"io.servicetalk.http.netty.http2.decoderEnforceMaxRstFramesPerWindow.maxRstFramesPerWindow";
private static final String SECONDS_PER_WINDOW_PROPERTY_NAME =
"io.servicetalk.http.netty.http2.decoderEnforceMaxRstFramesPerWindow.secondsPerWindow";

private static final int MAX_CONSECUTIVE_EMPTY_FRAMES;
private static final int SECONDS_PER_WINDOW;
// Default values are taken from Netty's AbstractHttp2ConnectionHandlerBuilder
private static final int MAX_RST_FRAMES_PER_WINDOW = parseProperty(MAX_RST_FRAMES_PER_WINDOW_PROPERTY_NAME,
parseProperty(MAX_CONSECUTIVE_EMPTY_FRAMES_PROPERTY_NAME, 200));
private static final int SECONDS_PER_WINDOW = parseProperty(SECONDS_PER_WINDOW_PROPERTY_NAME, 30);

@Nullable
private static final MethodHandle FLUSH_PREFACE;
Expand All @@ -75,10 +79,6 @@ final class OptimizedHttp2FrameCodecBuilder extends Http2FrameCodecBuilder {
}
FLUSH_PREFACE = flushPreface;

// Default values are taken from Netty's AbstractHttp2ConnectionHandlerBuilder
MAX_CONSECUTIVE_EMPTY_FRAMES = parseProperty(MAX_CONSECUTIVE_EMPTY_FRAMES_PROPERTY_NAME, 200);
SECONDS_PER_WINDOW = parseProperty(SECONDS_PER_WINDOW_PROPERTY_NAME, 30);

MethodHandle decoderEnforceMaxRstFramesPerWindow;
try {
// Find a new method that exists only in Netty starting from 4.1.100.Final:
Expand Down Expand Up @@ -163,7 +163,7 @@ private static Http2FrameCodecBuilder decoderEnforceMaxRstFramesPerWindow(
try {
// invokeExact requires return type cast to match the type signature
return (Http2FrameCodecBuilder) methodHandle.invokeExact(builderInstance,
MAX_CONSECUTIVE_EMPTY_FRAMES, SECONDS_PER_WINDOW);
MAX_RST_FRAMES_PER_WINDOW, SECONDS_PER_WINDOW);
} catch (Throwable t) {
throwException(t);
return builderInstance;
Expand Down

0 comments on commit 231ec64

Please sign in to comment.