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

Remove JsonView filter #11189

Merged
merged 4 commits into from
Sep 18, 2024
Merged

Remove JsonView filter #11189

merged 4 commits into from
Sep 18, 2024

Conversation

dstepanov
Copy link
Contributor

This PR changes how JsonView used to work before. Instead of detecting the JsonView annotation using the filter and invoking serialization, the responsibility is moved to the JsonMapper. This requires the method annotation to be correctly propagated to the serializer; we need to copy the method annotations if the argument is unwrapped. Jax-RS also expects that.

The property to enable the view is jackson.json-view.enabled, but that also worked for Serde, so we need to fix it before the next minor release.

@dstepanov dstepanov added the type: improvement A minor improvement to an existing feature label Sep 16, 2024
@dstepanov
Copy link
Contributor Author

@sdelamo Is there something wrong with the test I wrote? It looks like the configuration is not applied for GraalVM

@yawkat
Copy link
Member

yawkat commented Sep 17, 2024

maybe the metadata is lost when running without reflection?

@dstepanov
Copy link
Contributor Author

Looks like Jackson needs reflective metadata to read the view annotation

@@ -64,13 +65,24 @@ public JsonMediaTypeCodec(ObjectMapper objectMapper,
* @param applicationConfiguration The common application configurations
* @param codecConfiguration The configuration for the codec
*/
@Inject
public JsonMediaTypeCodec(BeanProvider<ObjectMapper> objectMapper,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we deprecate this constructor?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see: #11194

@@ -75,7 +76,6 @@ public JsonStreamMediaTypeCodec(ObjectMapper objectMapper,
* @param applicationConfiguration The common application configurations
* @param codecConfiguration The configuration for the codec
*/
@Inject
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we deprecate this constructor?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see: #11194

Copy link
Contributor

@sdelamo sdelamo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add the deprecation notices #11194 even if the classes are themselves already deprecated.

Copy link

@Requires(property = JsonViewServerFilter.PROPERTY_JSON_VIEW_ENABLED)
@ServerFilter("/**")
@Internal
public class JsonViewServerFilter implements Ordered {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strictly speaking we have to leave this in place and deprecate it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? It's internal.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh in that case no problem :)

@dstepanov dstepanov merged commit e73bacb into 4.7.x Sep 18, 2024
21 checks passed
@dstepanov dstepanov deleted the removeviewfilter branch September 18, 2024 15:17
yawkat added a commit to micronaut-projects/micronaut-serialization that referenced this pull request Oct 8, 2024
yawkat added a commit to micronaut-projects/micronaut-serialization that referenced this pull request Oct 8, 2024
* Implement JsonView support
Complementary to micronaut-projects/micronaut-core#11189 .

* review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: improvement A minor improvement to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants