From 2d9e9dc35b0074035df6093a8e7c05b3fb861f03 Mon Sep 17 00:00:00 2001 From: Clement Escoffier Date: Tue, 31 Aug 2021 19:53:29 +0200 Subject: [PATCH 1/3] Update Vert.x version to 4.1.3 and Mutiny bindings to 2.13.0 --- bom/application/pom.xml | 6 +++--- independent-projects/resteasy-reactive/pom.xml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bom/application/pom.xml b/bom/application/pom.xml index 5a28a7cab7d31..907bf88c6cf23 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -53,7 +53,7 @@ 1.2.0 1.0.13 2.6.0 - 2.12.0 + 2.13.0 3.9.1 1.2.1 1.3.5 @@ -109,7 +109,7 @@ 1.16.1.Final 1.8.7.Final 3.4.2.Final - 4.1.2 + 4.1.3 4.5.13 4.4.14 4.1.4 @@ -131,7 +131,7 @@ 12.1.7.Final 4.4.1.Final 2.9.2 - 4.1.65.Final + 4.1.67.Final 1.0.3 3.4.2.Final 1.0.0 diff --git a/independent-projects/resteasy-reactive/pom.xml b/independent-projects/resteasy-reactive/pom.xml index 2aed06eaa2350..f43d16df34780 100644 --- a/independent-projects/resteasy-reactive/pom.xml +++ b/independent-projects/resteasy-reactive/pom.xml @@ -52,7 +52,7 @@ 1.1.6 1.0.0 1.6.0 - 4.1.2 + 4.1.3 4.4.0 1.0.0.Final 2.0.0.Final From fb4c1cbb92ad588bd48cec3d07a223ddfec73a91 Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Tue, 17 Aug 2021 09:36:14 +1000 Subject: [PATCH 2/3] Add some substitutions for Brotli and Zstd --- extensions/vertx-http/runtime/pom.xml | 5 + .../HttpContentCompressorSubstitutions.java | 115 ++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/graal/HttpContentCompressorSubstitutions.java diff --git a/extensions/vertx-http/runtime/pom.xml b/extensions/vertx-http/runtime/pom.xml index a1f7c667077d8..fabcf3c34282d 100644 --- a/extensions/vertx-http/runtime/pom.xml +++ b/extensions/vertx-http/runtime/pom.xml @@ -53,6 +53,11 @@ + + org.graalvm.nativeimage + svm + provided + org.junit.jupiter diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/graal/HttpContentCompressorSubstitutions.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/graal/HttpContentCompressorSubstitutions.java new file mode 100644 index 0000000000000..37dac442fbcf1 --- /dev/null +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/graal/HttpContentCompressorSubstitutions.java @@ -0,0 +1,115 @@ +package io.quarkus.vertx.http.runtime.graal; + +import static io.netty.handler.codec.http.HttpHeaderValues.DEFLATE; +import static io.netty.handler.codec.http.HttpHeaderValues.GZIP; +import static io.netty.handler.codec.http.HttpHeaderValues.X_DEFLATE; +import static io.netty.handler.codec.http.HttpHeaderValues.X_GZIP; + +import java.util.function.BooleanSupplier; + +import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; + +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.embedded.EmbeddedChannel; +import io.netty.handler.codec.compression.ZlibWrapper; +import io.netty.handler.codec.http2.CompressorHttp2ConnectionEncoder; +import io.netty.handler.codec.http2.Http2Exception; + +public class HttpContentCompressorSubstitutions { + + @TargetClass(className = "io.netty.handler.codec.compression.ZstdEncoder", onlyWith = IsZstdAbsent.class) + public static final class ZstdEncoderFactorySubstitution { + + @Substitute + protected ByteBuf allocateBuffer(ChannelHandlerContext ctx, ByteBuf msg, boolean preferDirect) throws Exception { + throw new UnsupportedOperationException(); + } + + @Substitute + protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) { + throw new UnsupportedOperationException(); + } + + @Substitute + public void flush(final ChannelHandlerContext ctx) { + throw new UnsupportedOperationException(); + } + } + + @TargetClass(className = "io.netty.handler.codec.compression.BrotliEncoder", onlyWith = IsBrotliAbsent.class) + public static final class BrEncoderFactorySubstitution { + + @Substitute + protected ByteBuf allocateBuffer(ChannelHandlerContext ctx, ByteBuf msg, boolean preferDirect) throws Exception { + throw new UnsupportedOperationException(); + } + + @Substitute + protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) { + throw new UnsupportedOperationException(); + } + } + + @TargetClass(CompressorHttp2ConnectionEncoder.class) + public static final class CompressorHttp2ConnectionSubstitute { + + @Substitute + protected EmbeddedChannel newContentCompressor(ChannelHandlerContext ctx, CharSequence contentEncoding) + throws Http2Exception { + if (GZIP.contentEqualsIgnoreCase(contentEncoding) || X_GZIP.contentEqualsIgnoreCase(contentEncoding)) { + return newCompressionChannel(ctx, ZlibWrapper.GZIP); + } + if (DEFLATE.contentEqualsIgnoreCase(contentEncoding) || X_DEFLATE.contentEqualsIgnoreCase(contentEncoding)) { + return newCompressionChannel(ctx, ZlibWrapper.ZLIB); + } + // 'identity' or unsupported + return null; + } + + @Alias + private EmbeddedChannel newCompressionChannel(final ChannelHandlerContext ctx, ZlibWrapper wrapper) { + throw new UnsupportedOperationException(); + } + } + + public static class IsZstdAbsent implements BooleanSupplier { + + private boolean zstdAbsent; + + public IsZstdAbsent() { + try { + Class.forName("com.github.luben.zstd.Zstd"); + zstdAbsent = false; + } catch (ClassNotFoundException e) { + zstdAbsent = true; + } + } + + @Override + public boolean getAsBoolean() { + return zstdAbsent; + } + } + + public static class IsBrotliAbsent implements BooleanSupplier { + + private boolean brotliAbsent; + + public IsBrotliAbsent() { + try { + Class.forName("com.aayushatharva.brotli4j.encoder.Encoder"); + brotliAbsent = false; + } catch (ClassNotFoundException e) { + brotliAbsent = true; + } + } + + @Override + public boolean getAsBoolean() { + return brotliAbsent; + } + } +} From a3d5b90cc5fbe17ae79864c0f3868369715d8d46 Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Wed, 1 Sep 2021 09:28:47 +1000 Subject: [PATCH 3/3] Fix some tests the broke due to default change The max attribute size changed in vert.x --- ...anDefaultFormAttributeMultipartFormInputTest.java | 8 +++++++- .../TooLargeFormAttributeMultipartFormInputTest.java | 12 ++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/multipart/LargerThanDefaultFormAttributeMultipartFormInputTest.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/multipart/LargerThanDefaultFormAttributeMultipartFormInputTest.java index 5489e49172b3f..225943678fa69 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/multipart/LargerThanDefaultFormAttributeMultipartFormInputTest.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/multipart/LargerThanDefaultFormAttributeMultipartFormInputTest.java @@ -39,7 +39,7 @@ public JavaArchive get() { return ShrinkWrap.create(JavaArchive.class) .addClasses(Resource.class, Data.class) .addAsResource(new StringAsset( - "quarkus.http.limits.max-form-attribute-size=4K"), + "quarkus.http.limits.max-form-attribute-size=120K"), "application.properties"); } }); @@ -49,6 +49,12 @@ public JavaArchive get() { @Test public void test() throws IOException { String fileContents = new String(Files.readAllBytes(FILE.toPath()), StandardCharsets.UTF_8); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < 10; ++i) { + sb.append(fileContents); + } + fileContents = sb.toString(); + Assertions.assertTrue(fileContents.length() > HttpServerOptions.DEFAULT_MAX_FORM_ATTRIBUTE_SIZE); given() .multiPart("text", fileContents) diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/multipart/TooLargeFormAttributeMultipartFormInputTest.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/multipart/TooLargeFormAttributeMultipartFormInputTest.java index 6699beab8c705..ef3d755319168 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/multipart/TooLargeFormAttributeMultipartFormInputTest.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/multipart/TooLargeFormAttributeMultipartFormInputTest.java @@ -66,9 +66,13 @@ public void clearDirectory() { @Test public void test() throws IOException { - String formAttrSourceFileContents = new String(Files.readAllBytes(FORM_ATTR_SOURCE_FILE.toPath()), - StandardCharsets.UTF_8); - Assertions.assertTrue(formAttrSourceFileContents.length() > HttpServerOptions.DEFAULT_MAX_FORM_ATTRIBUTE_SIZE); + String fileContents = new String(Files.readAllBytes(FORM_ATTR_SOURCE_FILE.toPath()), StandardCharsets.UTF_8); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < 10; ++i) { + sb.append(fileContents); + } + fileContents = sb.toString(); + Assertions.assertTrue(fileContents.length() > HttpServerOptions.DEFAULT_MAX_FORM_ATTRIBUTE_SIZE); given() .multiPart("active", "true") .multiPart("num", "25") @@ -76,7 +80,7 @@ public void test() throws IOException { .multiPart("htmlFile", HTML_FILE, "text/html") .multiPart("xmlFile", XML_FILE, "text/xml") .multiPart("txtFile", TXT_FILE, "text/plain") - .multiPart("name", formAttrSourceFileContents) + .multiPart("name", fileContents) .accept("text/plain") .when() .post("/test")