Skip to content

Change default for TokenStreamFactory.Feature.INTERN_FIELD_NAMES to false #378

Closed
@cowtowncoder

Description

@cowtowncoder

(note: 3.0 will split JsonFactory into TokenStreamFactory base for all codecs, and JsonFactory just or json -- features to be part of former)

Since there are many users concerned about downsides of interning JSON property field names (and similarly for other dataformats, as per #332, it may make sense to consider changing default setting for INTERN_FIELD_NAMES feature for Jackson 3.x.

As a background, the main measurable benefit of using String.intern() on field names (and ONLY once usually, first time a new symbol is encountered -- it is not an on-going cost) is that matching of JSON property name to Java logical property can usually be done with simple identity check.
This speeds up data-binding by ~10% for many cases (see jackson-benchmarks).

But doing this will not usually have benefits if:

  1. Databinding is not used (unless caller makes some use of identity comparisons)
  2. If number of symbols used is big (due to overhead by JVM for managing big number -- hundreds of thousands or millions -- of Strings off-heap)

To me it seems reasonable that for use case of ObjectMapper implicitly creating a JsonFactory (or similar factory for other formats) default should remain the same. But I have no objection to using different default to "direct" usage.
There are multiple ways to achieve this: one possibility would just be to make ObjectMapper explicitly set the default if it directly creates the factory; but not change setting if it is passed one.
And then JsonFactory base class can just default to intern()ing being disabled by default.

Other than this I am also open to possibility of changing defaults for databinding use case, if all major framework developers choose explicitly disabled settings as their baseline.
(authors/contributors of major frameworks like Spring Boot, Dropwizard, Restlet etc etc please send your notes to mailing list, or directly to developers -- I am not looking forward to "voting" here; but I will add condensed notes here for any input we receive).

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.xIssues to be only tackled for Jackson 3.x, not 2.x

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions