refactor(gateway-engine): disable more obscure Jackson features & use `findAndAddModules`
MODIFY
gateway/engine/core/src/main/java/io/apiman/gateway/engine/policy/IPolicyProbe.java
gateway/engine/core/src/main/java/io/apiman/gateway/engine/policy/IPolicyProbe.java
package io.apiman.gateway.engine.policy;
-import io.apiman.common.util.JsonUtil;
import io.apiman.gateway.engine.async.IAsyncResultHandler;
import io.apiman.gateway.engine.beans.IPolicyProbeRequest;
import io.apiman.gateway.engine.beans.IPolicyProbeResponse;
import io.apiman.gateway.engine.beans.exceptions.ConfigurationParseException;
-import io.apiman.gateway.engine.policy.IPolicy;
-import io.apiman.gateway.engine.policy.IPolicyContext;
-import io.apiman.gateway.engine.policy.ProbeContext;
+import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.databind.json.JsonMapper;
/**
* @author Marc Savy {@literal <marc@blackparrotlabs.io>}
*/
public interface IPolicyProbe<C, P extends IPolicyProbeRequest> extends IPolicy {
- ObjectMapper mapper = JsonUtil.getObjectMapper();
+ ObjectMapper mapper = JsonMapper
+ .builder()
+ .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
+ .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
+ .findAndAddModules()
+ .build();
/**
* Return the class to unmarshall the raw probe request JSON configuration into.

MODIFY
gateway/engine/policies/src/main/java/io/apiman/gateway/engine/policies/AbstractMappedPolicy.java
gateway/engine/policies/src/main/java/io/apiman/gateway/engine/policies/AbstractMappedPolicy.java
@@ -28,18 +28,6 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.json.JsonMapper;
-import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
-import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
-import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
-
-import static com.fasterxml.jackson.core.json.JsonReadFeature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER;
-import static com.fasterxml.jackson.core.json.JsonReadFeature.ALLOW_JAVA_COMMENTS;
-import static com.fasterxml.jackson.core.json.JsonReadFeature.ALLOW_LEADING_DECIMAL_POINT_FOR_NUMBERS;
-import static com.fasterxml.jackson.core.json.JsonReadFeature.ALLOW_NON_NUMERIC_NUMBERS;
-import static com.fasterxml.jackson.core.json.JsonReadFeature.ALLOW_SINGLE_QUOTES;
-import static com.fasterxml.jackson.core.json.JsonReadFeature.ALLOW_TRAILING_COMMA;
-import static com.fasterxml.jackson.core.json.JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS;
-import static com.fasterxml.jackson.core.json.JsonReadFeature.ALLOW_UNQUOTED_FIELD_NAMES;
/**
* A base class for policy impls that uses Jackson to parse configuration info.
@@ -52,22 +40,11 @@ public abstract class AbstractMappedPolicy<C> implements IPolicy {
private static final ObjectMapper mapper = JsonMapper
.builder()
- // (mostly) match the JSON5 spec.
- .enable(ALLOW_UNQUOTED_FIELD_NAMES)
- .enable(ALLOW_TRAILING_COMMA)
- .enable(ALLOW_SINGLE_QUOTES)
- .enable(ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER)
- .enable(ALLOW_NON_NUMERIC_NUMBERS)
- .enable(ALLOW_JAVA_COMMENTS)
- .enable(ALLOW_LEADING_DECIMAL_POINT_FOR_NUMBERS)
- .enable(ALLOW_UNESCAPED_CONTROL_CHARS)
// Avoid weird floating point timestamps
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
// Enable various Java 8 and library data structures to be serialized
- .addModule(new JavaTimeModule())
- .addModule(new ParameterNamesModule())
- .addModule(new Jdk8Module())
+ .findAndAddModules()
.build();
/**

MODIFY
gateway/platforms/war/wildfly8/gateway/src/main/webapp/WEB-INF/jboss-deployment-structure.xml
gateway/platforms/war/wildfly8/gateway/src/main/webapp/WEB-INF/jboss-deployment-structure.xml
<deployment>
<dependencies>
<module name="org.infinispan" />
- <module name="org.hibernate" />
<module name="org.apache.log4j" /> <!-- Remove? -->
<module name="org.slf4j" /> <!-- Remove? -->
<module name="org.picketbox" />
- <module name="org.hibernate.commons-annotations" />
<module name="org.jboss.logging" services="import"/>
</dependencies>
<exclusions>

refactor(gateway-engine): disable more obscure Jackson features & use `findAndAddModules`