From 3003a0257f6388a023e0bbcb81f61e82fdff4b70 Mon Sep 17 00:00:00 2001 From: Joe Di Pol Date: Wed, 25 Oct 2023 15:43:03 -0700 Subject: [PATCH] Fix #7783: max-payload-size is parsed as an Integer --- .../io/helidon/webserver/SocketConfiguration.java | 2 +- .../io/helidon/webserver/MaxPayloadSizeTest.java | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/webserver/webserver/src/main/java/io/helidon/webserver/SocketConfiguration.java b/webserver/webserver/src/main/java/io/helidon/webserver/SocketConfiguration.java index 98a5019e7d0..67093ff1251 100644 --- a/webserver/webserver/src/main/java/io/helidon/webserver/SocketConfiguration.java +++ b/webserver/webserver/src/main/java/io/helidon/webserver/SocketConfiguration.java @@ -587,7 +587,7 @@ default B config(Config config) { config.get("backlog").asInt().ifPresent(this::backlog); config.get("max-header-size").asInt().ifPresent(this::maxHeaderSize); config.get("max-initial-line-length").asInt().ifPresent(this::maxInitialLineLength); - config.get("max-payload-size").asInt().ifPresent(this::maxPayloadSize); + config.get("max-payload-size").asLong().ifPresent(this::maxPayloadSize); DeprecatedConfig.get(config, "timeout-millis", "timeout") .asInt() diff --git a/webserver/webserver/src/test/java/io/helidon/webserver/MaxPayloadSizeTest.java b/webserver/webserver/src/test/java/io/helidon/webserver/MaxPayloadSizeTest.java index 4fd6071e8d7..b978a0c68a8 100644 --- a/webserver/webserver/src/test/java/io/helidon/webserver/MaxPayloadSizeTest.java +++ b/webserver/webserver/src/test/java/io/helidon/webserver/MaxPayloadSizeTest.java @@ -17,6 +17,7 @@ package io.helidon.webserver; import java.nio.charset.Charset; +import java.util.Map; import java.util.concurrent.CompletionException; import java.util.concurrent.Flow; import java.util.concurrent.TimeUnit; @@ -25,6 +26,8 @@ import io.helidon.common.http.DataChunk; import io.helidon.common.http.Http; import io.helidon.common.http.MediaType; +import io.helidon.config.Config; +import io.helidon.config.ConfigSources; import io.helidon.webclient.WebClient; import io.helidon.webclient.WebClientRequestBuilder; import io.helidon.webclient.WebClientResponse; @@ -188,6 +191,18 @@ public void testMixedGoodAndBadPayloads() { assertThat(response.status().code(), is(Http.Status.OK_200.code())); } + /** + * Verify fix for 7783 + */ + @Test + public void testMaxLongMaxPayloadSizeFromConfig() { + final long MAX_PAYLOAD_SIZE = Long.MAX_VALUE; + Config justConfig = Config.just(ConfigSources.create(Map.of("max-payload-size", Long.toString(MAX_PAYLOAD_SIZE))).build()); + WebServer webServer = WebServer.builder().config(justConfig).build(); + assertThat(webServer.configuration().namedSocket(WebServer.DEFAULT_SOCKET_NAME).get().maxPayloadSize(), + is(Long.MAX_VALUE)); + } + /** * Publishes the same chunk multiple times. If number of times is greater than * one, Helidon will send content using chunked encoding.