Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Migrate from Jackson 2 to Jackson 3.
See the Jackson 3 Migration guide for more background on the changes that were required.
Decorators
In Jackson 3.0,
ObjectMapperandJsonFactoryare now immutable (previously, they were mutable).An
ObjectMapperis now configured and created via aMapperBuilder. In addition, Jackson now has subclasses ofObjectMapperandMapperBuilderspecific to different data formats (e.g.JsonMapperandJsonMapper.Builderfor json, andYAMLMapperandYAMLMapper.Builderfor yaml).A
JsonFactoryis now configured and created via aJsonFactoryBuilder. In addition, Jackson now has a higher levelTokenStreamFactoryandTSFBuilderas a superclass to support different data formats (e.g.YAMLFactoryandYAMLFactoryBuilder).Previously, logstash-logback-encoder had the following decorators:
JsonFactoryDecoratorJsonFactory(andObjectMapperindirectly viajsonFactory.getCodec())<jsonFactoryDecorator class="SomeJsonFactoryDecorator"/>JsonGeneratorDecoratorJsonGenerator<jsonGeneratorDecorator class="SomeJsonGeneratorDecorator"/>To support the changes in Jackson 3.0,
JsonFactoryDecoratorand all its implementations were refactored.Now, logstash-logback-encoder has the following decorators:
MapperBuilderDecorator, which decorates aMapperBuilder(or subclass),TokenStreamFactoryBuilderDecorator, which decorates aTSFBuilder(or subclass), andJsonGeneratorDecorator, which decorates aJsonGenerator. This is generally to wrap aJsonGeneratorand delegate to it, sinceJsonGeneratoris immutable.All decorators are now registered via
<decorator class="SomeDecorator"/>.Replacements for previous decorator implementations provided by logstash-logback-encoder are as follows:
JsonFactoryDecoratorMapperBuilderDecoratororTokenStreamFactoryBuilderDecoratorCompositeJsonFactoryDecoratorCompositeMapperBuilderDecoratororCompositeTokenStreamFactoryBuilderDecoratorCharacterEscapesJsonFactoryDecoratorCharacterEscapesDecoratorEscapeNonAsciiJsonFactoryDecoratorCborJsonFactoryDecoratorYamlJsonFactoryDecoratorSmileJsonFactoryDecoratorJsonGeneratorDecoratorJsonGeneratorDecoratorPrettyPrintingJsonGeneratorDecoratorPrettyPrintingDecoratorMaskingJsonGeneratorDecoratorMaskingJsonGeneratorDecorator(no change)FeatureJsonFactoryDecoratorFeatureJsonGeneratorDecoratorCborFeatureJsonGeneratorDecoratorCborWriteFeatureDecorator(see Feature Decorators section)SmileFeatureJsonGeneratorDecoratorSmileWriteFeatureDecorator(see Feature Decorators section)YamlFeatureJsonGeneratorDecoratorYamlWriteFeatureDecorator(see Feature Decorators section)NullJsonFactoryDecoratorNullJsonGeneratorDecoratorFeature Decorators
Feature enums were refactored drastically in Jackson 3.0.
As a result, the decorators used to configure features have changed.
The following table shows which feature decorator to use to configure each Jackson feature type.
TokenStreamFactory.Featurenet.logstash.logback.decorate.TokenStreamFactoryFeatureDecoratorMapperFeaturenet.logstash.logback.decorate.MapperFeatureDecoratorSerializationFeaturenet.logstash.logback.decorate.SerializationFeatureDecoratorStreamWriteFeaturenet.logstash.logback.decorate.StreamWriteFeatureDecoratorJsonNodeFeaturenet.logstash.logback.decorate.JsonNodeFeatureDecoratorEnumFeaturenet.logstash.logback.decorate.EnumFeatureDecoratorDateTimeFeaturenet.logstash.logback.decorate.DateTimeFeatureDecoratorJsonWriteFeaturenet.logstash.logback.decorate.json.JsonWriteFeatureDecoratorSmileWriteFeaturenet.logstash.logback.decorate.smile.SmileWriteFeatureDecoratorYAMLWriteFeaturenet.logstash.logback.decorate.yaml.YamlWriteFeatureDecoratorCBORWriteFeaturenet.logstash.logback.decorate.cbor.CborWriteFeatureDecoratorThe following old decorators were replaced by one or more of the above feature decorators
(depending on where the feature moved in Jackson 3.0):
FeatureJsonFactoryDecoratorFeatureJsonGeneratorDecoratorCborFeatureJsonGeneratorDecoratorSmileFeatureJsonGeneratorDecoratorYamlFeatureJsonGeneratorDecoratorEscapeNonAsciiJsonFactoryDecoratorData Format
Previously, non-JSON data formats were enabled via a
JsonFactoryDecorator. For example:Now, the data format is controlled by a
DataFormatFactory, with built-in support provided forjson(the default),yaml,cbor, andsmile.For example:
Or:
Also, the feature decorator class names for the configuring data format features has changed
(see also the Feature Decorators section):
SmileFeatureJsonGeneratorDecoratorSmileWriteFeatureDecoratorYamlFeatureJsonGeneratorDecoratorYamlWriteFeatureDecoratorCborFeatureJsonGeneratorDecoratorCborWriteFeatureDecoratorMaskers
In Jackson 3.0,
JsonStreamContextwas replaced withTokenStreamContext.Therefore, references to
JsonStreamContextin logstash-logback-encoder'sFieldMaskerandValueMaskerwere changed toTokenStreamContext.JsonFactoryAware
Previously, a
JsonProvidercould implementJsonFactoryAwareto be injected with theJsonFactory.Now,
JsonFactoryAwarehas been removed.Instead, a
JsonProvidercan implementObjectMapperAwareto be injected with theObjectMapper.This change was made because in Jackson 3.0:
JsonFactoryis now specific to json (i.e. other data formats use subclasses ofTokenStreamFactory),ObjectMappercan no longer be retrieved from aJsonFactory, but aTokenStreamFactorycan be retrieved from anObjectMapper.