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

XmlMapper.copy() doesn't properly copy internal configurations #233

Closed
gtrog opened this issue May 16, 2017 · 2 comments
Closed

XmlMapper.copy() doesn't properly copy internal configurations #233

gtrog opened this issue May 16, 2017 · 2 comments
Milestone

Comments

@gtrog
Copy link
Contributor

gtrog commented May 16, 2017

Affected version: all versions (up to jackson-dataformat-xml-2.9.0.pr3)

Currently, if you create an instance of XmlMapper and register a module with it, any copies of that mapper will not contain the registered module. This behavior is different from the behavior of ObjectMapper, which retains all other configurations, such as modules, serialization/deserialization configs, etc.

final XmlMapper mapper = new XmlMapper();
mapper.registerModule(new JaxbAnnotationModule());

final XmlMapper mapperWithoutModule = mapper.copy();

I think this could be easily resolved by following the same copy-constructor pattern that ObjectMapper uses to copy itself, and then just invoking super's constructor in XmlMapper's copy constructor.

I'll have a PR up shortly.

@gtrog gtrog changed the title XmlMapper.copy() doesn't properly copy internal configurations XmlMapper.copy() doesn't properly copy internal configurations May 16, 2017
@cowtowncoder
Copy link
Member

Thank you for reporting this: yes, copy() should retain module settings.

I added one important comment; I think serializer provider does need to be copied. Otherwise LGTM.

@cowtowncoder cowtowncoder modified the milestones: 2.3., 2.8.9 May 18, 2017
@cowtowncoder
Copy link
Member

Thank you! I also backported this in 2.8, to be included in 2.8.9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants