Skip to content

Commit df3bfaf

Browse files
committed
Make 0 the disable value for ping duration
1 parent 027f677 commit df3bfaf

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

http-clients/netty-nio-client/src/main/java/software/amazon/awssdk/http/nio/netty/Http2Configuration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public interface Builder extends CopyableBuilder<Builder, Http2Configuration> {
122122
* Sets the period that the Netty client will send {@code PING} frames to the remote endpoint to check the
123123
* health of the connection. The default value is {@link
124124
* software.amazon.awssdk.http.nio.netty.internal.NettyConfiguration#HTTP2_CONNECTION_PING_TIMEOUT_SECONDS}. To
125-
* disable this feature, set a duration of {@link Integer#MAX_VALUE} milliseconds or greater.
125+
* disable this feature, set a duration of 0.
126126
*
127127
* @param healthCheckPingPeriod The ping period.
128128
* @return This builder for method chaining.

http-clients/netty-nio-client/src/main/java/software/amazon/awssdk/http/nio/netty/internal/ChannelPipelineInitializer.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import static software.amazon.awssdk.http.nio.netty.internal.ChannelAttributeKey.PROTOCOL_FUTURE;
1919
import static software.amazon.awssdk.http.nio.netty.internal.NettyConfiguration.HTTP2_CONNECTION_PING_TIMEOUT_SECONDS;
20+
import static software.amazon.awssdk.utils.NumericUtils.saturatedCast;
2021
import static software.amazon.awssdk.utils.StringUtils.lowerCase;
2122

2223
import io.netty.channel.Channel;
@@ -147,8 +148,8 @@ private void configureHttp2(Channel ch, ChannelPipeline pipeline) {
147148
pipeline.addLast(new Http2SettingsFrameHandler(ch, clientMaxStreams, channelPoolRef));
148149
if (healthCheckPingPeriod == null) {
149150
pipeline.addLast(new Http2PingHandler(HTTP2_CONNECTION_PING_TIMEOUT_SECONDS * 1_000));
150-
} else if (healthCheckPingPeriod.toMillis() <= Integer.MAX_VALUE) {
151-
pipeline.addLast(new Http2PingHandler((int) healthCheckPingPeriod.toMillis()));
151+
} else if (healthCheckPingPeriod.toMillis() > 0) {
152+
pipeline.addLast(new Http2PingHandler(saturatedCast(healthCheckPingPeriod.toMillis())));
152153
}
153154
}
154155

http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/internal/http2/PingTimeoutTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,12 @@
3737
import io.netty.handler.codec.http2.Http2FrameLogger;
3838
import io.netty.handler.codec.http2.Http2Headers;
3939
import io.netty.handler.codec.http2.Http2MultiplexHandler;
40-
import io.netty.handler.codec.http2.Http2PingFrame;
4140
import io.netty.handler.codec.http2.Http2Settings;
4241
import io.netty.handler.logging.LogLevel;
4342
import io.netty.handler.logging.LoggingHandler;
4443
import io.netty.handler.ssl.SslContext;
4544
import io.netty.handler.ssl.util.SelfSignedCertificate;
4645
import java.nio.ByteBuffer;
47-
import java.nio.charset.StandardCharsets;
4846
import java.time.Duration;
4947
import java.time.Instant;
5048
import java.util.concurrent.CompletableFuture;
@@ -109,9 +107,9 @@ public void pingHealthCheck_10sec() {
109107
}
110108

111109
@Test
112-
public void pingHealthCheck_IntMax_disabled() throws Exception {
110+
public void pingHealthCheck_0_disabled() throws Exception {
113111
expected.expect(TimeoutException.class);
114-
CompletableFuture<Void> requestFuture = makeRequest(Duration.ofMillis(Integer.MAX_VALUE));
112+
CompletableFuture<Void> requestFuture = makeRequest(Duration.ofMillis(0));
115113
try {
116114
requestFuture.get(8, TimeUnit.SECONDS);
117115
} finally {

0 commit comments

Comments
 (0)