Add opt-in Jackson Blackbird optimization to ObjectMappers - #3534
Add opt-in Jackson Blackbird optimization to ObjectMappers#3534parker89 wants to merge 1 commit into
Conversation
Generate changelog in
|
| } | ||
|
|
||
| /** Like {@link #newServerSmileMapper()}, optionally enabling Jackson optimization modules (Blackbird). */ | ||
| public static SmileMapper newServerSmileMapper(boolean useOptimizations) { |
There was a problem hiding this comment.
Did you have other optimizations in mind down the line?
I wonder if we should name this something like "newSingleInstantiatedServerSmileMapper" or something to make it clear that this should not be called multiple times, and then enable blackbird by default for this case.
Maybe we can write an errorprone check(? e.g. only created in a final variable in a class - though this is a bit restrictive)
|
I think a big issue I have with this change is that it is not obvious that calling We have quite a bit of code internally that uses this pattern; existing code won't be affected (which is good), but new code can very easily be written in a way that causes the leak. Using a memoization approach might be better, with a separate API that makes it very obvious that you are getting a shared ObjectMapper, not a new one. |
Adds opt-in Jackson Blackbird support to
ObjectMappers(off by default).ObjectMapperOptimizations.createModules(boolean)plus new server/client mapper overloads registerBlackbirdModuleonly when explicitly requested.