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

Allow customizing ObjectReader via @CustomDeserialization in Resteasy #35138

Merged
merged 1 commit into from
Aug 2, 2023

Conversation

Sgitario
Copy link
Contributor

@Sgitario Sgitario commented Aug 1, 2023

To customize the com.fasterxml.jackson.databind.ObjectReader to read JSON requests with unquoted field names:

@CustomDeserialization(SupportUnquotedFields.class)
@POST
@Path("/use-of-custom-deserializer")
public void useOfCustomSerializer(User request) {
    // ...
}

where SupportUnquotedFields is a BiFunction defined as so:

public static class SupportUnquotedFields implements BiFunction<ObjectMapper, Type, ObjectReader> {

    @Override
    public ObjectReader apply(ObjectMapper objectMapper, Type type) {
        return objectMapper.reader().with(JsonReadFeature.ALLOW_UNQUOTED_FIELD_NAMES);
    }
}

Fix #35122

To customize the `com.fasterxml.jackson.databind.ObjectReader` to read JSON requests with unquoted field names:

```java
@CustomDeserialization(SupportUnquotedFields.class)
@post
@path("/use-of-custom-deserializer")
public void useOfCustomSerializer(User request) {
    // ...
}
```

where `SupportUnquotedFields` is a `BiFunction` defined as so:

```java
public static class SupportUnquotedFields implements BiFunction<ObjectMapper, Type, ObjectReader> {

    @OverRide
    public ObjectReader apply(ObjectMapper objectMapper, Type type) {
        return objectMapper.reader().with(JsonReadFeature.ALLOW_UNQUOTED_FIELD_NAMES);
    }
}
```
@geoand
Copy link
Contributor

geoand commented Aug 1, 2023

I am going to remove the backport label from this

@geoand geoand added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Aug 1, 2023
@github-actions
Copy link

github-actions bot commented Aug 1, 2023

🙈 The PR is closed and the preview is expired.

@quarkus-bot
Copy link

quarkus-bot bot commented Aug 1, 2023

Failing Jobs - Building 3cda45d

Status Name Step Failures Logs Raw logs
Virtual Thread Support Tests Native - Messaging Build Failures Logs Raw logs

Full information is available in the Build summary check run.

Failures

⚙️ Virtual Thread Support Tests Native - Messaging #

📦 kafka-virtual-threads

io.quarkus.it.vthreads.kafka.VirtualThreadITCase.testAlert - More details - Source on GitHub

org.awaitility.core.ConditionTimeoutException: 
Assertion condition defined as a io.quarkus.it.vthreads.kafka.VirtualThreadTest Expected at least one request matching: {
  "urlPath" : "/price/alert",

io.quarkus.it.vthreads.kafka.VirtualThreadITCase.testAlertMessage - More details - Source on GitHub

org.awaitility.core.ConditionTimeoutException: 
Assertion condition defined as a io.quarkus.it.vthreads.kafka.VirtualThreadTest Expected more than or exactly 10 requests matching the following pattern but received 4:
{

@Sgitario
Copy link
Contributor Author

Sgitario commented Aug 2, 2023

I think the test failures are unrelated

@geoand
Copy link
Contributor

geoand commented Aug 2, 2023

Yup

@Sgitario Sgitario merged commit a8be00f into quarkusio:main Aug 2, 2023
@quarkus-bot quarkus-bot bot removed the triage/waiting-for-ci Ready to merge when CI successfully finishes label Aug 2, 2023
@Sgitario Sgitario deleted the 35122 branch August 2, 2023 05:11
@quarkus-bot quarkus-bot bot added this to the 3.3 - main milestone Aug 2, 2023
Sgitario added a commit to Sgitario/quarkus that referenced this pull request Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow customization of ObjectReader/ObjectWriter during serialization
2 participants