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

Support both filters and views in AbstractJackson2HttpMessageConverter [SPR-17209] #21742

Closed
spring-issuemaster opened this issue Aug 23, 2018 · 2 comments

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Aug 23, 2018

Daniel Raniz Raneland opened SPR-17209 and commented

Currently, if you set a view class on the MappingJacksonValue it will pick that and ignore any filter provider.

Both of these could be supported by changing:

ObjectWriter objectWriter;
if (serializationView != null) {
	objectWriter = this.objectMapper.writerWithView(serializationView);
}
else if (filters != null) {
	objectWriter = this.objectMapper.writer(filters);
}
else {
	objectWriter = this.objectMapper.writer();
}
if (javaType != null && javaType.isContainerType()) {
	objectWriter = objectWriter.forType(javaType);
}

into

ObjectWriter objectWriter = this.objectMapper.writer();
if (filters != null) {
    objectWriter = objectWriter.with(filters);
}
if (serializationView != null) {
    objectWriter = objectWriter.withView(serializationView);
}
if (javaType != null && javaType.isContainerType()) {
    objectWriter = objectWriter.forType(javaType);
}

We're using version 4.3.17, but as far as I can tell (by looking at GitHub) this is still the case for 5.0.


Affects: 4.3.17

Issue Links:

  • #11815 Integrate Jackson @JsonView
  • #17187 Support Jackson @JsonFilter

Referenced from: pull request #1940, and commits a44fe4c, 03f1920, 069704f

Backported to: 4.3.19

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Aug 23, 2018

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Aug 24, 2018

Juergen Hoeller commented

I've rolled this into master now in a slightly extended revision, consistently using writerWithView like in our other Jackson converters but applying a filter thereafter. This is consistent between AbstractJackson2HttpMessageConverter and AbstractJackson2View.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.