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

[RESTEasy] enabling GZIP compression results in corrupted chunked response #18469

Closed
keitaf opened this issue Jul 6, 2021 · 5 comments · Fixed by #19808
Closed

[RESTEasy] enabling GZIP compression results in corrupted chunked response #18469

keitaf opened this issue Jul 6, 2021 · 5 comments · Fixed by #19808
Labels
area/resteasy-classic kind/bug Something isn't working
Milestone

Comments

@keitaf
Copy link
Contributor

keitaf commented Jul 6, 2021

Describe the bug

A REST endpoint returns a corrupted data when GZIP compression is enabled on the endpoint but it's returning a chunked and uncompressed response.

Here is a sample code to reproduce.

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @GZIP
    public Map<String, String> hello() {
        var builder = new HashMap<String, String>();
        for (int i = 0; i < 100000; i++) {
            builder.put("key"+i, "Hello RESTEasy\n");
        }
        return builder;
    }

When you run this app with ./gradlew quarkusDev -Dquarkus.http.enable-compression=true and call GET /hello without specifying Accept-Encoding header, it returns a corrupted JSON like the following.

y\n","key67078":"Hello RESTEasy\n","key92012":"Hello RESTEasy\n","key67079":"Hello RESTEasy\n","key92013":"Hello RESTEasy\n","key92014":"Hello RESTEasy\n","key92015":"Hello RESTEasy\n"...

Calling the endpoint with Accept-Encoding: gzip returns a correct response.

Also, calling the same endpoint again results in some error ("connection timeout" or "invalid chunk size")

Expected behavior

The endpoint should return a "valid" JSON.

{
    "key2100": "Hello RESTEasy\n",
    "key2101": "Hello RESTEasy\n",
    "key2110": "Hello RESTEasy\n",
    "key2111": "Hello RESTEasy\n",
    "key2112": "Hello RESTEasy\n",
    "key2106": "Hello RESTEasy\n",
...

Actual behavior

The endpoint returns a corrupted data.

y\n","key67078":"Hello RESTEasy\n","key92012":"Hello RESTEasy\n","key67079":"Hello RESTEasy\n","key92013":"Hello RESTEasy\n","key92014":"Hello RESTEasy\n","key92015":"Hello RESTEasy\n"...

Also, calling the same endpoint again results in some error ("connection timeout" or "invalid chunk size")

To Reproduce

Steps to reproduce the behavior:

  1. Follow this guide to create a new gradle project
  2. Modify MyResource.hello() as follows (to produce a large enough response that needs to be chunked).
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @GZIP
    public Map<String, String> hello() {
        var builder = new HashMap<String, String>();
        for (int i = 0; i < 100000; i++) {
            builder.put("key"+i, "Hello RESTEasy\n");
        }
        return builder;
    }
  1. Start in the dev mode with GZIP compression enabled by running ./gradlew quarkusDev -Dquarkus.http.enable-compression=true
  2. Call the endpoint by running curl localhost:8080/hello

Configuration

quarkus.http.enable-compression=true

Environment:

Output of uname -a or ver

Darwin M-Q636 20.5.0 Darwin Kernel Version 20.5.0: Sat May 8 05:10:33 PDT 2021; root:xnu-7195.121.3~9/RELEASE_X86_64 x86_64

Output of java -version

openjdk version "15.0.2" 2021-01-19
OpenJDK Runtime Environment (build 15.0.2+7-27)
OpenJDK 64-Bit Server VM (build 15.0.2+7-27, mixed mode, sharing)

Quarkus version or git rev

2.0.0-FINAL
Also reproduceable in 1.13.4.Final

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

Gradle 6.8.3

@keitaf keitaf added the kind/bug Something isn't working label Jul 6, 2021
@geoand
Copy link
Contributor

geoand commented Jul 7, 2021

cc @ronsigal @jamezp

@stuartwdouglas
Copy link
Member

This sounds like netty/netty#11358

Unfortunately it has not made it into a released version of Netty yet.

@ThoSap
Copy link

ThoSap commented Aug 16, 2021

@geoand could we include the netty 4.1.66 or even better 4.1.67 update in Quarkus 2.2.0 as this includes @stuartwdouglas awesome fix for this issue? 😏

@geoand
Copy link
Contributor

geoand commented Aug 16, 2021

That's up to @cescoffier to decide

@cescoffier
Copy link
Member

We can try with Netty 4.1.67. However, updating netty is never a peaceful journey. I will open a PR tomorrow to see how far it goes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/resteasy-classic kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants