Skip to content

Abuse of new ObjectMapper() #79

@xuyang2

Description

@xuyang2

Found 100+ occurrences: new ObjectMapper()
ObjectMapper is heavy-weight and thread safe. It should be resused.

according to JacksonFAQ:

Is ObjectMapper thread-safe?
Short answer: yes
Long answer: yes, as long as you always configure instance before use, and do not call configure methods during operation (or synchronize such calls appropriately). Usually it is better to construct separate mapper instance if configurations differ in any case.
Further: it is beneficial to use just one instance (or small number of instances) for data binding; many optimizations for reuse (of symbol tables, some buffers) depend on ObjectMapper instances being reused.
For more information, check out JacksonFAQThreadSafety

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomers — GitHub surfaces this in the Contribute tab

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions