Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.67.x-blue] Fix json serialization and deserialization of decimal numbers with big scale. #3072

Open
wants to merge 9 commits into
base: 7.67.x-blue
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ protected void configureMarshaller(Set<Class<?>> classes, final ClassLoader clas
deserializeObjectMapper.setConfig(objectMapper.getDeserializationConfig()
.with(introspectorPair)
.with(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
// .with(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)
.without(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));

objectMapper.configure(MapperFeature.USE_STD_BEAN_NAMING, this.useStrictJavaBeans);
Expand Down Expand Up @@ -437,6 +438,9 @@ public <T> T unmarshall(String serializedInput, Class<T> type) {

try {
Class<?> actualType = classesSet.contains(type) ? Object.class : type;
if (actualType != null && actualType.getPackage() != null && actualType.getPackage().getName().endsWith(".dmn")) {
deserializeObjectMapper.setConfig(deserializeObjectMapper.getDeserializationConfig().with(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS));
}
return (T) unwrap(deserializeObjectMapper.readValue(serializedInput, actualType));
} catch (IOException e) {
throw new MarshallingException("Error unmarshalling input", e);
Expand All @@ -450,6 +454,9 @@ public <T> T unmarshall(byte[] serializedInput, Class<T> type) {

try {
Class<?> actualType = classesSet.contains(type) ? Object.class : type;
if (actualType != null && actualType.getPackage() != null && actualType.getPackage().getName().endsWith(".dmn")) {
deserializeObjectMapper.setConfig(deserializeObjectMapper.getDeserializationConfig().with(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS));
}
return (T) unwrap(deserializeObjectMapper.readValue(serializedInput, actualType));
} catch (IOException e) {
throw new MarshallingException("Error unmarshalling input", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import javax.xml.namespace.QName;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.cfg.JsonNodeFeature;
import org.kie.api.builder.ReleaseId;
import org.kie.api.runtime.KieRuntimeFactory;
import org.kie.dmn.api.core.DMNContext;
Expand Down Expand Up @@ -87,7 +89,9 @@ public class ModelEvaluatorServiceBase {
.addSerializer(org.kie.dmn.feel.lang.types.impl.ComparablePeriod.class,
new DMNFEELComparablePeriodSerializer()))
.disable(com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.disable(com.fasterxml.jackson.databind.SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS);
.disable(com.fasterxml.jackson.databind.SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS)
.configure(JsonNodeFeature.STRIP_TRAILING_BIGDECIMAL_ZEROES, false)
.configure(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS, true);

public ModelEvaluatorServiceBase(KieServerRegistry context) {
this.context = context;
Expand Down
Loading