From 880a148d38d7fc8774a46ed7ac37f172018c5c47 Mon Sep 17 00:00:00 2001 From: Anna Koskinen Date: Mon, 31 Jul 2023 22:41:44 +0300 Subject: [PATCH] chore: bump jackson-databind from 2.9.10.8 to 2.15.2 in /addon Also add implementations for new Jackson API and reset changed defaults. --- addon/pom.xml | 7 ++- .../serializers/BeanSerializerDelegator.java | 46 ++++++++++++++++--- .../ThemeGradientColorBeanSerializer.java | 29 ++++++++++++ .../addon/charts/util/ChartSerialization.java | 8 +++- 4 files changed, 80 insertions(+), 10 deletions(-) diff --git a/addon/pom.xml b/addon/pom.xml index fa2329220..c8466bf29 100644 --- a/addon/pom.xml +++ b/addon/pom.xml @@ -252,7 +252,12 @@ com.fasterxml.jackson.core jackson-databind - 2.9.10.8 + 2.15.2 + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + 2.15.2 com.vaadin diff --git a/addon/src/main/java/com/vaadin/addon/charts/model/serializers/BeanSerializerDelegator.java b/addon/src/main/java/com/vaadin/addon/charts/model/serializers/BeanSerializerDelegator.java index 616fb8f28..3120c4b2d 100644 --- a/addon/src/main/java/com/vaadin/addon/charts/model/serializers/BeanSerializerDelegator.java +++ b/addon/src/main/java/com/vaadin/addon/charts/model/serializers/BeanSerializerDelegator.java @@ -22,6 +22,7 @@ import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.BeanPropertyWriter; import com.fasterxml.jackson.databind.ser.impl.BeanAsArraySerializer; import com.fasterxml.jackson.databind.ser.impl.ObjectIdWriter; import com.fasterxml.jackson.databind.ser.std.BeanSerializerBase; @@ -46,14 +47,29 @@ public BeanSerializerDelegator(BeanSerializerBase source, super(source, objectIdWriter); } - public BeanSerializerDelegator(BeanSerializerBase source, String[] toIgnore) { + @Deprecated + public BeanSerializerDelegator(BeanSerializerBase source, + String[] toIgnore) { super(source, toIgnore); } - protected BeanSerializerDelegator(BeanSerializerBase source, Set toIgnore) { + @Deprecated + protected BeanSerializerDelegator(BeanSerializerBase source, + Set toIgnore) { super(source, toIgnore); } + protected BeanSerializerDelegator(BeanSerializerBase source, + Set toIgnore, Set toInclude) { + super(source, toIgnore, toInclude); + } + + protected BeanSerializerDelegator(BeanSerializerBase source, + BeanPropertyWriter[] properties, + BeanPropertyWriter[] filteredProperties) { + super(source, properties, filteredProperties); + } + public BeanSerializerDelegator(BeanSerializerBase source, Object filterId) { super(source, null, filterId); } @@ -66,23 +82,39 @@ public BeanSerializerDelegator(BeanSerializerBase source, } @Override - public BeanSerializerBase withObjectIdWriter(ObjectIdWriter objectIdWriter) { - return new BeanSerializerDelegator(this, objectIdWriter); + public BeanSerializerBase withObjectIdWriter( + ObjectIdWriter objectIdWriter) { + return new BeanSerializerDelegator<>(this, objectIdWriter); } @Override + @Deprecated protected BeanSerializerBase withIgnorals(String[] toIgnore) { - return new BeanSerializerDelegator(this, toIgnore); + return new BeanSerializerDelegator<>(this, toIgnore); } @Override + @Deprecated protected BeanSerializerBase withIgnorals(Set toIgnore) { - return new BeanSerializerDelegator(this, toIgnore); + return new BeanSerializerDelegator<>(this, toIgnore); } @Override public BeanSerializerBase withFilterId(Object filterId) { - return new BeanSerializerDelegator(this, filterId); + return new BeanSerializerDelegator<>(this, filterId); + } + + @Override + protected BeanSerializerBase withByNameInclusion(Set toIgnore, + Set toInclude) { + return new BeanSerializerDelegator<>(this, toIgnore, toInclude); + } + + @Override + protected BeanSerializerBase withProperties(BeanPropertyWriter[] properties, + BeanPropertyWriter[] filteredProperties) { + return new BeanSerializerDelegator<>(this, properties, + filteredProperties); } @Override diff --git a/addon/src/main/java/com/vaadin/addon/charts/model/serializers/ThemeGradientColorBeanSerializer.java b/addon/src/main/java/com/vaadin/addon/charts/model/serializers/ThemeGradientColorBeanSerializer.java index ec11455a3..ebee32097 100644 --- a/addon/src/main/java/com/vaadin/addon/charts/model/serializers/ThemeGradientColorBeanSerializer.java +++ b/addon/src/main/java/com/vaadin/addon/charts/model/serializers/ThemeGradientColorBeanSerializer.java @@ -23,6 +23,7 @@ import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.ser.BeanPropertyWriter; import com.fasterxml.jackson.databind.ser.impl.BeanAsArraySerializer; import com.fasterxml.jackson.databind.ser.impl.ObjectIdWriter; import com.fasterxml.jackson.databind.ser.std.BeanSerializerBase; @@ -44,16 +45,29 @@ public ThemeGradientColorBeanSerializer(BeanSerializerBase source, super(source, objectIdWriter); } + @Deprecated public ThemeGradientColorBeanSerializer(BeanSerializerBase source, String[] toIgnore) { super(source, toIgnore); } + @Deprecated protected ThemeGradientColorBeanSerializer(BeanSerializerBase source, Set toIgnore) { super(source, toIgnore); } + protected ThemeGradientColorBeanSerializer(BeanSerializerBase source, + Set toIgnore, Set toInclude) { + super(source, toIgnore, toInclude); + } + + protected ThemeGradientColorBeanSerializer(BeanSerializerBase source, + BeanPropertyWriter[] properties, + BeanPropertyWriter[] filteredProperties) { + super(source, properties, filteredProperties); + } + public ThemeGradientColorBeanSerializer(BeanSerializerBase source, Object filterId) { super(source, null, filterId); @@ -65,11 +79,13 @@ public BeanSerializerBase withObjectIdWriter(ObjectIdWriter objectIdWriter) { } @Override + @Deprecated protected BeanSerializerBase withIgnorals(String[] toIgnore) { return new ThemeGradientColorBeanSerializer(this, toIgnore); } @Override + @Deprecated protected BeanSerializerBase withIgnorals(Set toIgnore) { return new ThemeGradientColorBeanSerializer(this, toIgnore); } @@ -79,6 +95,19 @@ public BeanSerializerBase withFilterId(Object filterId) { return new ThemeGradientColorBeanSerializer(this, filterId); } + @Override + protected BeanSerializerBase withByNameInclusion(Set toIgnore, + Set toInclude) { + return new ThemeGradientColorBeanSerializer(this, toIgnore, toInclude); + } + + @Override + protected BeanSerializerBase withProperties(BeanPropertyWriter[] properties, + BeanPropertyWriter[] filteredProperties) { + return new ThemeGradientColorBeanSerializer(this, properties, + filteredProperties); + } + @Override protected BeanSerializerBase asArraySerializer() { // copied from BeanSerializer diff --git a/addon/src/main/java/com/vaadin/addon/charts/util/ChartSerialization.java b/addon/src/main/java/com/vaadin/addon/charts/util/ChartSerialization.java index 51fcaa5e4..0daaf58dc 100644 --- a/addon/src/main/java/com/vaadin/addon/charts/util/ChartSerialization.java +++ b/addon/src/main/java/com/vaadin/addon/charts/util/ChartSerialization.java @@ -25,7 +25,9 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectWriter; +import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.ser.BeanSerializerModifier; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.vaadin.addon.charts.ChartOptions; import com.vaadin.addon.charts.model.AbstractConfigurationObject; import com.vaadin.addon.charts.model.serializers.AxisListSerializer; @@ -35,10 +37,10 @@ import com.vaadin.addon.charts.model.serializers.DefaultBeanSerializerModifier; import com.vaadin.addon.charts.model.serializers.GradientColorStopsSerializer; import com.vaadin.addon.charts.model.serializers.InstantSerializer; -import com.vaadin.addon.charts.model.serializers.StringSerializer; import com.vaadin.addon.charts.model.serializers.PaneListSerializer; import com.vaadin.addon.charts.model.serializers.SolidColorSerializer; import com.vaadin.addon.charts.model.serializers.StopSerializer; +import com.vaadin.addon.charts.model.serializers.StringSerializer; import com.vaadin.addon.charts.model.serializers.TimeUnitMultiplesSerializer; /** @@ -87,7 +89,9 @@ public static ObjectMapper createObjectMapper(BeanSerializerModifier modifier) { .registerModule(PaneListSerializer.getModule()) .registerModule(DateSerializer.getModule()) .registerModule(InstantSerializer.getModule()) - .registerModule(StringSerializer.getModule()); + .registerModule(StringSerializer.getModule()) + .registerModule(new JavaTimeModule()).disable( + SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS); // serializer modifier used when basic serializer isn't enough return mapper.setSerializerFactory(mapper.getSerializerFactory()