Hi,

Looking through the source code to check up on a vulnerability in Jackson,
I saw that there's a couple of places on master where new *ObjectMapper*s
are being created and not reused.

I've found through experience that not reusing ObjectMappers (especially in
loops) can have a very detrimental impact on performance. Reuse is
recommended:
https://github.com/FasterXML/jackson-docs/wiki/Presentation:-Jackson-Performance#basics-things-you-should-do-anyway
- "1. Reuse heavy-weight objects: ObjectMapper (data-binding)"
ObjectMapper is thread safe once configured.

The older uses just create them statically:

   - org.apache.solr.analytics.AnalyticsRequestParser
   - org.apache.solr.prometheus.scraper.SolrScraper

The new ones I see currently are in

   -
   
org.apache.solr.security.AuditLoggerPlugin.JSONAuditEventFormatter.formatEvent(AuditEvent)
   - org.apache.solr.packagemanager.PackageUtils.getMapper()
   -
   org.apache.solr.util.SolrJacksonAnnotationInspector.createObjectMapper()

I don't know whether these uses are necessarily going to cause performance
issues or not, but it's generally best not to new them up inline.

Colvin

Reply via email to