[
https://issues.apache.org/jira/browse/AVRO-4042?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17878820#comment-17878820
]
ASF subversion and git services commented on AVRO-4042:
-------------------------------------------------------
Commit 971b0a861f8a2d2aca10b39ca95b4c18d3056539 in avro's branch
refs/heads/dependabot/maven/lang/java/grpc.version-1.66.0 from Andrew
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=971b0a861 ]
[AVRO-4042] Precache ObjectMapper to avoid recreation (#3123)
ObjectMapper is an expensive, immutable and thread-safe object.
By creating just one instance, we can avoid unnecessary recalculations.
> Reuse ObjectMapper in SchemaBuilder & JacksonUtils
> --------------------------------------------------
>
> Key: AVRO-4042
> URL: https://issues.apache.org/jira/browse/AVRO-4042
> Project: Apache Avro
> Issue Type: Improvement
> Components: java
> Affects Versions: 1.11.3
> Reporter: Andrew Craig
> Assignee: Oscar Westra van Holthe - Kind
> Priority: Minor
> Labels: pull-request-available
> Fix For: 1.12.1
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> Currently, calling `JacksonUtils.toJsonNode(obj)`,
> `JacksonUtils.objectToMap(obj)` or `SchemaBuilder.toJsonNode(obj)` recreate
> at least one new instance of Jackson ObjectMapper each time.
> ObjectMapper is an expensive object to create, but is thread-safe. We can see
> in various other locations within Avro that we reuse the same object, and
> avoid recreation.
> We can perform the same reuse here - and only create the ObjectMapper once.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)