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

Add a way to combine more than one AnnotationIntrospector in Jackson2ObjectMapperBuilder instead of overriding it #22830

Closed
anatoliy-balakirev opened this issue Apr 24, 2019 · 3 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@anatoliy-balakirev
Copy link

Enhancement

Today there is an option to provide custom annotationIntrospector to the Jackson2ObjectMapperBuilder via Jackson2ObjectMapperBuilderCustomizer:

    @Bean
    public Jackson2ObjectMapperBuilderCustomizer myCustomizer() {
        return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.annotationIntrospector(new MyIntrospector());
    }

However, in that way I'm replacing existing introspector. So if some other introspectors were added by some libs - they will be just lost and today there seems to be no option to extend existing ones instead.

Would be good to adjust org.springframework.http.converter.json.Jackson2ObjectMapperBuilder to either provide some way to get currently configured annotationIntrospector (so that I can use something like AnnotationIntrospector.pair to combine it with mine) or to have some other way to add new introspector to current one instead of replacing it.

@anatoliy-balakirev anatoliy-balakirev changed the title Add an way to append annotationIntrospector to Jackson2ObjectMapperBuilder instead of overriding it Add a way to append annotationIntrospector to Jackson2ObjectMapperBuilder instead of overriding it Apr 24, 2019
@snicoll snicoll transferred this issue from spring-projects/spring-boot Apr 24, 2019
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Apr 24, 2019
@philwebb
Copy link
Member

philwebb commented Apr 25, 2019

Thanks for the suggestion. Although Jackson2ObjectMapperBuilderCustomizer is part of Spring Boot I believe it's Jackson2ObjectMapperBuilder that would need to change. Since that's part of Spring Framework, we'll migrate this issue for that team to consider.

@sdeleuze sdeleuze self-assigned this Apr 26, 2019
@dazito
Copy link

dazito commented Jan 30, 2020

Hi, is there any feedback regarding this issue? I see it is waiting for triage :(

@rstoyanchev rstoyanchev assigned rstoyanchev and unassigned sdeleuze Jan 31, 2020
@rstoyanchev
Copy link
Contributor

rstoyanchev commented Jan 31, 2020

I think we can add an extra annotationIntrospector method that takes Function<AnnotationIntrospector, AnnotationIntrospector> annotationIntrospector, so you can choose to use AnnotationIntrospectorPair and combine with the existing one, if configured.

@rstoyanchev rstoyanchev added in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jan 31, 2020
@rstoyanchev rstoyanchev added this to the 5.2.4 milestone Jan 31, 2020
@rstoyanchev rstoyanchev changed the title Add a way to append annotationIntrospector to Jackson2ObjectMapperBuilder instead of overriding it Add a way to combine more than one AnnotationIntrospector in Jackson2ObjectMapperBuilder instead of overriding it Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

6 participants