Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Vert.x 4.5.7 #39764

Merged
merged 2 commits into from
Mar 29, 2024
Merged
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
4 changes: 2 additions & 2 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
<wildfly-client-config.version>1.0.1.Final</wildfly-client-config.version>
<wildfly-elytron.version>2.3.1.Final</wildfly-elytron.version>
<jboss-threads.version>3.6.0.Final</jboss-threads.version>
<vertx.version>4.5.5</vertx.version>
<vertx.version>4.5.7</vertx.version>
<httpclient.version>4.5.14</httpclient.version>
<httpcore.version>4.4.16</httpcore.version>
<httpasync.version>4.1.5</httpasync.version>
Expand All @@ -144,7 +144,7 @@
<infinispan.version>15.0.0.Final</infinispan.version>
<infinispan.protostream.version>5.0.1.Final</infinispan.protostream.version>
<caffeine.version>3.1.5</caffeine.version>
<netty.version>4.1.107.Final</netty.version>
<netty.version>4.1.108.Final</netty.version>
<brotli4j.version>1.16.0</brotli4j.version>
<reactive-streams.version>1.0.4</reactive-streams.version>
<jboss-logging.version>3.5.3.Final</jboss-logging.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ NativeImageConfigBuildItem build(
.addRuntimeInitializedClass("io.netty.handler.codec.http.websocketx.extensions.compression.DeflateDecoder")
.addRuntimeInitializedClass("io.netty.handler.codec.http.websocketx.WebSocket00FrameEncoder")
.addRuntimeInitializedClass("io.netty.handler.codec.compression.ZstdOptions")
.addRuntimeInitializedClass("io.netty.handler.codec.compression.ZstdConstants")
.addRuntimeInitializedClass("io.netty.handler.codec.compression.BrotliOptions");
} else {
log.debug("Not registering Netty HTTP classes as they were not found");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ public void flush(final ChannelHandlerContext ctx) {
}
}

@Substitute
@TargetClass(className = "io.netty.handler.codec.compression.ZstdConstants", onlyWith = IsZstdAbsent.class)
public static final class ZstdConstants {

// The constants make <clinit> calls to com.github.luben.zstd.Zstd so we cut links with that substitution.

static final int DEFAULT_COMPRESSION_LEVEL = 0;

static final int MIN_COMPRESSION_LEVEL = 0;

static final int MAX_COMPRESSION_LEVEL = 0;

static final int MAX_BLOCK_SIZE = 0;

static final int DEFAULT_BLOCK_SIZE = 0;
}

public static class IsZstdAbsent implements BooleanSupplier {

private boolean zstdAbsent;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
package io.quarkus.vertx.http.form;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.event.Observes;
import jakarta.inject.Inject;

import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusUnitTest;
import io.vertx.core.Vertx;
import io.vertx.core.http.HttpClient;
import io.vertx.core.http.HttpClientResponse;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.RequestOptions;
import io.vertx.ext.web.Router;
import io.vertx.ext.web.handler.BodyHandler;

public class FormTest {

private static final String APP_PROPS = """
quarkus.http.limits.max-form-fields=10
quarkus.http.limits.max-form-buffered-bytes=100
""";

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withApplicationRoot((jar) -> jar
.addAsResource(new StringAsset(APP_PROPS), "application.properties")
.addClasses(BeanRegisteringRouteUsingObserves.class));

@Inject
Vertx vertx;

@Test
public void testTooManyFields() throws Exception {
CountDownLatch latch = new CountDownLatch(1);
AtomicReference<HttpClientResponse> reference = new AtomicReference<>();
HttpClient client = vertx.createHttpClient();
client.request(new RequestOptions().setMethod(HttpMethod.POST).setAbsoluteURI("http://localhost:8081/form"))
.onComplete(ar -> {
var req = ar.result();
req.setChunked(true);
req.putHeader("content-type", "application/x-www-form-urlencoded");
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 20; i++) {
if (i > 0) {
sb.append('&');
}
sb.append("a").append(i).append("=").append("b");
}
req.write(sb.toString());
vertx.setTimer(10, id -> {
req.end();
});

req.response().onComplete(rc -> {
reference.set(rc.result());
latch.countDown();
});
});
latch.await(10, TimeUnit.SECONDS);
Assertions.assertEquals(400, reference.get().statusCode());
}

@Test
public void testOkForm() throws Exception {
CountDownLatch latch = new CountDownLatch(1);
AtomicReference<HttpClientResponse> reference = new AtomicReference<>();
HttpClient client = vertx.createHttpClient();
client.request(new RequestOptions().setMethod(HttpMethod.POST).setAbsoluteURI("http://localhost:8081/form"))
.onComplete(ar -> {
var req = ar.result();
req.setChunked(true);
req.putHeader("content-type", "application/x-www-form-urlencoded");
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 10; i++) {
if (i > 0) {
sb.append('&');
}
sb.append("a").append(i).append("=").append("b");
}
req.write(sb.toString());
vertx.setTimer(10, id -> {
req.end();
});

req.response().onComplete(rc -> {
reference.set(rc.result());
latch.countDown();
});
});
latch.await(10, TimeUnit.SECONDS);
Assertions.assertEquals(200, reference.get().statusCode());
}

@Test
public void testTooManyBytes() throws Exception {
CountDownLatch latch = new CountDownLatch(1);
AtomicReference<HttpClientResponse> reference = new AtomicReference<>();
HttpClient client = vertx.createHttpClient();
client.request(new RequestOptions().setMethod(HttpMethod.POST).setAbsoluteURI("http://localhost:8081/form"))
.onComplete(ar -> {
var req = ar.result();
req.setChunked(true);
req.putHeader("content-type", "application/x-www-form-urlencoded");
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 200; i++) {
sb.append("a");
}
req.write(sb.toString());
vertx.setTimer(10, id -> {
req.end("=b");
});

req.response().onComplete(rc -> {
reference.set(rc.result());
latch.countDown();
});
});
latch.await(10, TimeUnit.SECONDS);
Assertions.assertEquals(400, reference.get().statusCode());
}

@Test
public void testBytesOk() throws Exception {
CountDownLatch latch = new CountDownLatch(1);
AtomicReference<HttpClientResponse> reference = new AtomicReference<>();
HttpClient client = vertx.createHttpClient();
client.request(new RequestOptions().setMethod(HttpMethod.POST).setAbsoluteURI("http://localhost:8081/form"))
.onComplete(ar -> {
var req = ar.result();
req.setChunked(true);
req.putHeader("content-type", "application/x-www-form-urlencoded");
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 100; i++) {
sb.append("a");
}
req.write(sb.toString());
vertx.setTimer(10, id -> {
req.end("=b");
});

req.response().onComplete(rc -> {
reference.set(rc.result());
latch.countDown();
});
});
latch.await(10, TimeUnit.SECONDS);
Assertions.assertEquals(200, reference.get().statusCode());
}

@ApplicationScoped
static class BeanRegisteringRouteUsingObserves {

public void register(@Observes Router router) {

router
.post().order(Integer.MIN_VALUE).handler(rc -> {
rc.request().setExpectMultipart(true);
rc.next();
});
router.post().handler(BodyHandler.create());
router.post("/form")
.handler(rc -> {
rc.response().end("OK");
});
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ public class ServerLimitsConfig {
@ConfigItem(defaultValue = "2048")
public MemorySize maxFormAttributeSize;

/**
* Set the maximum number of fields of a form. Set to {@code -1} to allow unlimited number of attributes.
*/
@ConfigItem(defaultValue = "256")
public int maxFormFields;

/**
* Set the maximum number of bytes a server can buffer when decoding a form.
* Set to {@code -1} to allow unlimited length
**/
@ConfigItem(defaultValue = "1K")
public MemorySize maxFormBufferedBytes;

/**
* The maximum number of HTTP request parameters permitted for incoming requests.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ public static void applyCommonOptions(HttpServerOptions httpServerOptions,
httpServerOptions.setMaxHeaderSize(httpConfiguration.limits.maxHeaderSize.asBigInteger().intValueExact());
httpServerOptions.setMaxChunkSize(httpConfiguration.limits.maxChunkSize.asBigInteger().intValueExact());
httpServerOptions.setMaxFormAttributeSize(httpConfiguration.limits.maxFormAttributeSize.asBigInteger().intValueExact());
httpServerOptions.setMaxFormFields(httpConfiguration.limits.maxFormFields);
httpServerOptions.setMaxFormBufferedBytes(httpConfiguration.limits.maxFormBufferedBytes.asBigInteger().intValue());
httpServerOptions.setWebSocketSubProtocols(websocketSubProtocols);
httpServerOptions.setReusePort(httpConfiguration.soReusePort);
httpServerOptions.setTcpQuickAck(httpConfiguration.tcpQuickAck);
Expand Down Expand Up @@ -331,6 +333,8 @@ public static void applyCommonOptionsForManagementInterface(HttpServerOptions op
options.setMaxHeaderSize(httpConfiguration.limits.maxHeaderSize.asBigInteger().intValueExact());
options.setMaxChunkSize(httpConfiguration.limits.maxChunkSize.asBigInteger().intValueExact());
options.setMaxFormAttributeSize(httpConfiguration.limits.maxFormAttributeSize.asBigInteger().intValueExact());
options.setMaxFormFields(httpConfiguration.limits.maxFormFields);
options.setMaxFormBufferedBytes(httpConfiguration.limits.maxFormBufferedBytes.asBigInteger().intValue());
options.setMaxInitialLineLength(httpConfiguration.limits.maxInitialLineLength);
options.setWebSocketSubProtocols(websocketSubProtocols);
options.setAcceptBacklog(httpConfiguration.acceptBacklog);
Expand Down
2 changes: 1 addition & 1 deletion independent-projects/resteasy-reactive/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<version.surefire.plugin>3.2.5</version.surefire.plugin>
<mutiny.version>2.5.8</mutiny.version>
<smallrye-common.version>2.3.0</smallrye-common.version>
<vertx.version>4.5.5</vertx.version>
<vertx.version>4.5.7</vertx.version>
<rest-assured.version>5.4.0</rest-assured.version>
<commons-logging-jboss-logging.version>1.0.0.Final</commons-logging-jboss-logging.version>
<jackson-bom.version>2.17.0</jackson-bom.version>
Expand Down
Loading