diff --git a/extensions/resteasy-classic/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java b/extensions/resteasy-classic/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java index b78d5eec48b58..d2fcf7fd846d2 100644 --- a/extensions/resteasy-classic/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java +++ b/extensions/resteasy-classic/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java @@ -58,6 +58,7 @@ import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem; import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem; import io.quarkus.deployment.util.ServiceUtil; +import io.quarkus.resteasy.common.runtime.ResteasyCommonConfig; import io.quarkus.resteasy.common.runtime.ResteasyInjectorFactoryRecorder; import io.quarkus.resteasy.common.runtime.config.ResteasyConfigBuilder; import io.quarkus.resteasy.common.runtime.providers.ServerFormUrlEncodedProvider; @@ -65,10 +66,6 @@ import io.quarkus.resteasy.common.spi.ResteasyDotNames; import io.quarkus.resteasy.common.spi.ResteasyJaxrsProviderBuildItem; import io.quarkus.runtime.RuntimeValue; -import io.quarkus.runtime.annotations.ConfigGroup; -import io.quarkus.runtime.annotations.ConfigItem; -import io.quarkus.runtime.annotations.ConfigRoot; -import io.quarkus.runtime.configuration.MemorySize; public class ResteasyCommonProcessor { @@ -102,31 +99,6 @@ public class ResteasyCommonProcessor { private ResteasyCommonConfig resteasyCommonConfig; - @ConfigRoot(name = "resteasy") - public static final class ResteasyCommonConfig { - /** - * Enable gzip support for REST - */ - public ResteasyCommonConfigGzip gzip; - } - - @ConfigGroup - public static final class ResteasyCommonConfigGzip { - /** - * If gzip is enabled - */ - @ConfigItem - public boolean enabled; - /** - * Maximum deflated file bytes size - *

- * If the limit is exceeded, Resteasy will return Response - * with status 413("Request Entity Too Large") - */ - @ConfigItem(defaultValue = "10M") - public MemorySize maxInput; - } - @BuildStep void addStaticInitConfigSourceProvider( Capabilities capabilities, @@ -164,7 +136,7 @@ void disableDefaultExceptionMapper(BuildProducer system @BuildStep void setupGzipProviders(BuildProducer providers) { // If GZIP support is enabled, enable it - if (resteasyCommonConfig.gzip.enabled) { + if (resteasyCommonConfig.gzip().enabled()) { providers.produce(new ResteasyJaxrsProviderBuildItem(AcceptEncodingGZIPFilter.class.getName())); providers.produce(new ResteasyJaxrsProviderBuildItem(GZIPDecodingInterceptor.class.getName())); providers.produce(new ResteasyJaxrsProviderBuildItem(GZIPEncodingInterceptor.class.getName())); diff --git a/extensions/resteasy-classic/resteasy-common/runtime/src/main/java/io/quarkus/resteasy/common/runtime/ResteasyCommonConfig.java b/extensions/resteasy-classic/resteasy-common/runtime/src/main/java/io/quarkus/resteasy/common/runtime/ResteasyCommonConfig.java new file mode 100644 index 0000000000000..aebebd4bc9ce1 --- /dev/null +++ b/extensions/resteasy-classic/resteasy-common/runtime/src/main/java/io/quarkus/resteasy/common/runtime/ResteasyCommonConfig.java @@ -0,0 +1,36 @@ +package io.quarkus.resteasy.common.runtime; + +import static io.quarkus.runtime.annotations.ConfigPhase.BUILD_AND_RUN_TIME_FIXED; + +import io.quarkus.runtime.annotations.ConfigRoot; +import io.quarkus.runtime.configuration.MemorySize; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; + +@ConfigRoot(phase = BUILD_AND_RUN_TIME_FIXED) +@ConfigMapping(prefix = "quarkus.resteasy") +public interface ResteasyCommonConfig { + + /** + * Enable gzip support for REST + */ + ResteasyCommonConfigGzip gzip(); + + interface ResteasyCommonConfigGzip { + /** + * If gzip is enabled + */ + @WithDefault("false") + boolean enabled(); + + /** + * Maximum deflated file bytes size + *

+ * If the limit is exceeded, Resteasy will return Response + * with status 413("Request Entity Too Large") + */ + @WithDefault("10M") + MemorySize maxInput(); + } + +} diff --git a/extensions/resteasy-classic/resteasy-server-common/deployment/src/main/java/io/quarkus/resteasy/server/common/deployment/ResteasyServerCommonProcessor.java b/extensions/resteasy-classic/resteasy-server-common/deployment/src/main/java/io/quarkus/resteasy/server/common/deployment/ResteasyServerCommonProcessor.java index 3dedbf5ee5108..bee18043872b9 100644 --- a/extensions/resteasy-classic/resteasy-server-common/deployment/src/main/java/io/quarkus/resteasy/server/common/deployment/ResteasyServerCommonProcessor.java +++ b/extensions/resteasy-classic/resteasy-server-common/deployment/src/main/java/io/quarkus/resteasy/server/common/deployment/ResteasyServerCommonProcessor.java @@ -77,8 +77,8 @@ import io.quarkus.gizmo.Gizmo; import io.quarkus.jaxrs.spi.deployment.AdditionalJaxRsResourceMethodAnnotationsBuildItem; import io.quarkus.resteasy.common.deployment.JaxrsProvidersToRegisterBuildItem; -import io.quarkus.resteasy.common.deployment.ResteasyCommonProcessor.ResteasyCommonConfig; import io.quarkus.resteasy.common.runtime.QuarkusInjectorFactory; +import io.quarkus.resteasy.common.runtime.ResteasyCommonConfig; import io.quarkus.resteasy.common.spi.ResteasyDotNames; import io.quarkus.resteasy.server.common.runtime.QuarkusResteasyDeployment; import io.quarkus.resteasy.server.common.spi.AdditionalJaxRsResourceDefiningAnnotationBuildItem; @@ -421,9 +421,9 @@ public void build( deploymentCustomizer.getConsumer().accept(deployment); } - if (commonConfig.gzip.enabled) { + if (commonConfig.gzip().enabled()) { resteasyInitParameters.put(ResteasyContextParameters.RESTEASY_GZIP_MAX_INPUT, - Long.toString(commonConfig.gzip.maxInput.asLongValue())); + Long.toString(commonConfig.gzip().maxInput().asLongValue())); } resteasyInitParameters.put(ResteasyContextParameters.RESTEASY_UNWRAPPED_EXCEPTIONS, ArcUndeclaredThrowableException.class.getName()); diff --git a/extensions/resteasy-classic/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/standalone/ResteasyConfigurationMPConfig.java b/extensions/resteasy-classic/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/standalone/ResteasyConfigurationMPConfig.java index bdf70a82a1603..7c87d6b9426f5 100644 --- a/extensions/resteasy-classic/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/standalone/ResteasyConfigurationMPConfig.java +++ b/extensions/resteasy-classic/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/standalone/ResteasyConfigurationMPConfig.java @@ -67,6 +67,11 @@ public Set getInitParameterNames() { } private static Optional getGzipMaxInput(Config config) { + if (config.getOptionalValue("resteasy.gzip.max.input", String.class).isPresent()) { + // resteasy-specific properties have priority + return Optional.empty(); + } + Optional rawValue = config.getOptionalValue("quarkus.resteasy.gzip.max-input", MemorySize.class); if (rawValue.isEmpty()) {