quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.44k stars 2.58k forks source link

Resteasy Gzip max input with suffix format not working #39636

Closed rennanfelizardo closed 4 months ago

rennanfelizardo commented 4 months ago

Describe the bug

The documentation mentions that the quarkus.resteasy.gzip.max-input can be configured by providing a suffix format such as 100M.

https://github.com/quarkusio/quarkus/blob/26dd881b17ec5804ad5752fec804e515e1d2212d/docs/src/main/asciidoc/resteasy.adoc?plain=1#L725-L726

If the property is configured using the allowed suffix (check regex above), Resteasy considers it as an invalid format and falls back to the default value of 10mb.

A log message can also be identified in the log output.

RESTEASY002137: Invalid format for resteasy.gzip.max.input, using default value 10000000

The properties used in quarkus tests do not use such suffix, considering only the bytes format.

https://github.com/quarkusio/quarkus/blob/26dd881b17ec5804ad5752fec804e515e1d2212d/integration-tests/main/src/main/resources/application.properties#L32 https://github.com/quarkusio/quarkus/blob/26dd881b17ec5804ad5752fec804e515e1d2212d/extensions/resteasy-classic/resteasy-client/deployment/src/test/resources/client-using-gzip-application.properties#L2

In addition, Resteasy GZIPDecodingInterceptor only accepts a value up to 2147483647 (Integer.MAX_VALUE), which I think would worth mentioning in the documentation. https://github.com/resteasy/resteasy/blob/6.2.7.Final/resteasy-core/src/main/java/org/jboss/resteasy/plugins/interceptors/GZIPDecodingInterceptor.java

Expected behavior

Quarkus should be able to properly convert the size if a data storage unit is provided as a suffix

OR

Consider only bytes format

Actual behavior

Quarkus is not able to convert the data storage unit falling back to the default value of 10mb

How to Reproduce?

quarks-gzip-reproducer.zip

Output of uname -a or ver

No response

Output of java -version

openjdk 17.0.9 2023-10-17 OpenJDK Runtime Environment Temurin-17.0.9+9 (build 17.0.9+9) OpenJDK 64-Bit Server VM Temurin-17.0.9+9 (build 17.0.9+9, mixed mode)

Quarkus version or git rev

3.8.3

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

geoand commented 4 months ago

What configuration value did you use to cause the error message?

Asking because I was not able to reproduce the problem.

rennanfelizardo commented 4 months ago
quarkus.resteasy.gzip.enabled=true
quarkus.resteasy.gzip.max-input=1k

quarkus.rest-client.my-client.url=http://localhost:${quarkus.http.test-port:8081}

The problem happens whenever you configure the max-input property with a data storage unit suffix. [0-9]+[KkMmGgTtPpEeZzYy]?.

You can find the reproducer attached to the issue.

geoand commented 4 months ago

You can find the reproducer attached to the issue.

I tried the attached sample and could not reproduce the problem, which is why I asked :)

rennanfelizardo commented 4 months ago

Thanks for your return. I've implemented a test that reproduce the problem in the sample. Could you kindly confirm if the test is not reproducing the issue? I just ran it and I confirm on my side.

geoand commented 4 months ago

Thanks.

I'm not at a computer now, I'll try it next week.

geoand commented 4 months ago

The tests pass in the uploaded reproducer.

gsmet commented 4 months ago

@geoand the trick is that AFAICS the test is testing that the behavior is incorrect.

I think I have a fix, will push it soon.

gsmet commented 4 months ago

https://github.com/quarkusio/quarkus/pull/39828 should fix it.

Thanks for raising the issue as it was indeed concerning.