Skip to content

Client ResponseExceptionMapper cannot read Response Entity Twice after migration to 3.25.0 #49379

@gcuisinier

Description

@gcuisinier

Describe the bug

When using a custom Exception Mapper for REST client, we need to first

  • Try to parse the Response Body with a specific JSon structure to raise a proper exception
  • If fails, get the Response Body as String to raise a generic exception with specific message

For that we used :

  • response.bufferEntity() to allow reading multiple time
  • Then response.readEntity(ErrorMessage.class);
  • and finally response.readEntity(String.class)

Up to Quarkus 3.24.3, that seems working.
But when migrating to Quarkus 3.25.0, our tests are failing, saying that the Stream is already closed when trying to read the second time.

Expected behavior

Allow to read the entity multiple time if bufferEntity is called before

Actual behavior

Not allowed to read multiple time

How to Reproduce?

  1. Clone this repository : https://github.com/[gcuisinier/quarkus-bug-reproducer

  2. Switch to bug-response-entity-cannot-be-read-twice

  3. Run mvn -Dquarkus.platform.version=3.24.3 clean package
    This Should works

  4. run mvn -Dquarkus.platform.version=3.25.0 clean package
    This should failed on QuarkusTest.testStringResponse
    QuarkusTest.testStringResponse:35 expected: <UNMANAGED ERROR RETURNING STRING> but was: <Regression : Unable to read entity twice>

Output of uname -a or ver

No response

Output of java -version

QuarkusTest.testStringResponse:35 expected: but was:

Quarkus version or git rev

3.25.0

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

Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions