Remove unnecessary ObjectMapper configuration used specifically for deserialization.

Clearly, this configuration is 'unnecessary' because the ObjectMapper is used to serialize Objects to JSON in this converter.

Removes Mixin that virtually annotated application domain model object types with @JsonIgnoreProperties for unknown/unmapped properties.

Removes configuration to accept case insensitive Enum (String) values.

Resolves gh-67.
This commit is contained in:
John Blum
2020-05-08 00:54:14 -07:00
parent a3faf2584a
commit 8418082a00

View File

@@ -15,7 +15,6 @@
*/
package org.springframework.geode.data.json.converter.support;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
@@ -27,9 +26,9 @@ import com.fasterxml.jackson.databind.module.SimpleModule;
import org.springframework.core.convert.ConversionFailedException;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.geode.data.json.converter.ObjectToJsonConverter;
import org.springframework.geode.data.json.jackson.databind.serializer.BigDecimalSerializer;
import org.springframework.geode.data.json.jackson.databind.serializer.BigIntegerSerializer;
import org.springframework.geode.data.json.jackson.databind.serializer.TypelessCollectionSerializer;
import org.springframework.geode.jackson.databind.serializer.BigDecimalSerializer;
import org.springframework.geode.jackson.databind.serializer.BigIntegerSerializer;
import org.springframework.geode.jackson.databind.serializer.TypelessCollectionSerializer;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
@@ -87,9 +86,7 @@ public class JacksonObjectToJsonConverter implements ObjectToJsonConverter {
ObjectMapper objectMapper = new ObjectMapper()
.activateDefaultTypingAsProperty(null, DEFAULT_TYPING, AT_TYPE_METADATA_PROPERTY_NAME)
.addMixIn(NonAccessibleType.class, ObjectTypeMetadataMixin.class)
.addMixIn(Object.class, IgnorePropertiesMixin.class)
.configure(JsonGenerator.Feature.WRITE_BIGDECIMAL_AS_PLAIN, true)
.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, true)
.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);
objectMapper.registerModule(new SimpleModule(SPRING_BOOT_DATA_GEODE_JACKSON_MODULE_NAME, VERSION)
@@ -103,10 +100,6 @@ public class JacksonObjectToJsonConverter implements ObjectToJsonConverter {
@SuppressWarnings("unused")
private interface NonAccessibleType { }
@JsonIgnoreProperties(ignoreUnknown = true)
@SuppressWarnings("unused")
interface IgnorePropertiesMixin { }
@JsonTypeInfo(
use = JsonTypeInfo.Id.CLASS,
include = JsonTypeInfo.As.PROPERTY,