Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj
case "lazystartproducer":
case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true;
case "objectmapper":
case "objectMapper": target.setObjectMapper(property(camelContext, com.fasterxml.jackson.databind.ObjectMapper.class, value)); return true;
case "objectMapper": target.setObjectMapper(property(camelContext, tools.jackson.databind.ObjectMapper.class, value)); return true;
case "urischemaloader":
case "uriSchemaLoader": target.setUriSchemaLoader(property(camelContext, org.apache.camel.component.jsonvalidator.JsonUriSchemaLoader.class, value)); return true;
default: return false;
Expand Down Expand Up @@ -71,7 +71,7 @@ public Class<?> getOptionType(String name, boolean ignoreCase) {
case "lazystartproducer":
case "lazyStartProducer": return boolean.class;
case "objectmapper":
case "objectMapper": return com.fasterxml.jackson.databind.ObjectMapper.class;
case "objectMapper": return tools.jackson.databind.ObjectMapper.class;
case "urischemaloader":
case "uriSchemaLoader": return org.apache.camel.component.jsonvalidator.JsonUriSchemaLoader.class;
default: return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"disabledDeserializationFeatures": { "index": 7, "kind": "parameter", "displayName": "Disabled Deserialization Features", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Comma-separated list of Jackson DeserializationFeature enum values which will be disabled for parsing exchange body" },
"enabledDeserializationFeatures": { "index": 8, "kind": "parameter", "displayName": "Enabled Deserialization Features", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Comma-separated list of Jackson DeserializationFeature enum values which will be enabled for parsing exchange body" },
"errorHandler": { "index": 9, "kind": "parameter", "displayName": "Error Handler", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.jsonvalidator.JsonValidatorErrorHandler", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom ValidatorErrorHandler. The default error handler captures the errors and throws an exception." },
"objectMapper": { "index": 10, "kind": "parameter", "displayName": "Object Mapper", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "com.fasterxml.jackson.databind.ObjectMapper", "deprecated": false, "autowired": false, "secret": false, "description": "The used Jackson object mapper" },
"objectMapper": { "index": 10, "kind": "parameter", "displayName": "Object Mapper", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "tools.jackson.databind.ObjectMapper", "deprecated": false, "autowired": false, "secret": false, "description": "The used Jackson object mapper" },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thsi is a breaking change which must be documented in the upgrade guide

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no Jackson 3 support on Camel Quarkus yet.

@saravanakumar1987 saravanakumar1987 Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the upgrade guide and also added a new unit test for custom ObjectMapper with json validator.

"uriSchemaLoader": { "index": 11, "kind": "parameter", "displayName": "Uri Schema Loader", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.jsonvalidator.JsonUriSchemaLoader", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom schema loader allowing for adding custom format validation. The default implementation will create a schema loader that tries to determine the schema version from the $schema property of the specified schema." }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@
import java.net.*;
import java.util.Optional;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.networknt.schema.Schema;
import com.networknt.schema.SchemaLocation;
import com.networknt.schema.SchemaRegistry;
import com.networknt.schema.SchemaRegistryConfig;
import com.networknt.schema.SpecificationVersion;
import org.apache.camel.CamelContext;
import org.apache.camel.support.ResourceHelper;
import tools.jackson.databind.JsonNode;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.json.JsonMapper;

public class DefaultJsonUriSchemaLoader implements JsonUriSchemaLoader {

protected ObjectMapper mapper = new ObjectMapper();
protected ObjectMapper mapper = JsonMapper.builder().build();

protected SchemaRegistryConfig config = SchemaRegistryConfig.builder().build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

import java.util.Map;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.camel.Endpoint;
import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.annotations.Component;
import org.apache.camel.support.CamelContextHelper;
import org.apache.camel.support.DefaultComponent;
import tools.jackson.databind.ObjectMapper;

/**
* The JSON Schema Validator Component is for validating JSON against a schema.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
import java.util.HashSet;
import java.util.List;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.networknt.schema.Error;
import com.networknt.schema.Schema;
import org.apache.camel.Category;
Expand All @@ -35,6 +32,10 @@
import org.apache.camel.component.ResourceEndpoint;
import org.apache.camel.spi.UriEndpoint;
import org.apache.camel.spi.UriParam;
import tools.jackson.databind.DeserializationFeature;
import tools.jackson.databind.JsonNode;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.json.JsonMapper;

/**
* Validate JSON payloads using NetworkNT JSON Schema.
Expand Down Expand Up @@ -84,21 +85,23 @@ public void clearContentCache() {
@Override
protected void doInit() throws Exception {
super.doInit();
if (objectMapper == null) {
objectMapper = new ObjectMapper();
}

var builder = (objectMapper != null)
? objectMapper.rebuild()
: JsonMapper.builder();

if (enabledDeserializationFeatures != null) {
for (var featureName : enabledDeserializationFeatures.split(",")) {
var feature = DeserializationFeature.valueOf(featureName);
objectMapper.enable(feature);
builder.enable(DeserializationFeature.valueOf(featureName));
}
}
if (disabledDeserializationFeatures != null) {
for (var featureName : disabledDeserializationFeatures.split(",")) {
var feature = DeserializationFeature.valueOf(featureName);
objectMapper.disable(feature);
builder.disable(DeserializationFeature.valueOf(featureName));
}
}

objectMapper = builder.build();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import java.util.Collections;
import java.util.List;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.networknt.schema.Error;
import tools.jackson.core.JacksonException;
import tools.jackson.dataformat.yaml.YAMLMapper;

/**
* YAML DSL parser that tooling can use to parse Camel source files to check if they can be YAML parsed.
Expand All @@ -33,13 +33,13 @@
*/
public class YamlParser {

private final ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
private final YAMLMapper mapper = YAMLMapper.builder().build();

public List<Error> parse(File file) throws Exception {
public List<Error> parse(File file) {
try {
mapper.readTree(file);
return Collections.emptyList();
} catch (Exception e) {
} catch (JacksonException e) {
Error error = Error.builder()
.messageKey("parser")
.format(new MessageFormat(e.getClass().getName() + ": " + e.getMessage()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
import java.util.Locale;
import java.util.Optional;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.networknt.schema.Error;
import com.networknt.schema.Schema;
import com.networknt.schema.SchemaLocation;
import com.networknt.schema.SchemaRegistry;
import com.networknt.schema.SchemaRegistryConfig;
import com.networknt.schema.SpecificationVersion;
import tools.jackson.core.JacksonException;
import tools.jackson.databind.JsonNode;
import tools.jackson.dataformat.yaml.YAMLMapper;

/**
* YAML DSL validator that tooling can use to validate Camel source files if they can be parsed and are valid according
Expand All @@ -42,7 +42,7 @@ public class YamlValidator {
private static final String LOCATION = "/schema/camelYamlDsl.json";
private static final String LOCATION_CANONICAL = "/schema/camelYamlDsl-canonical.json";

private final ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
private final YAMLMapper mapper = YAMLMapper.builder().build();
private final boolean canonical;
private Schema schema;

Expand All @@ -58,14 +58,14 @@ public boolean isCanonical() {
return canonical;
}

public List<Error> validate(File file) throws Exception {
public List<Error> validate(File file) {
if (schema == null) {
init();
}
try {
var target = mapper.readTree(file);
return new ArrayList<>(schema.validate(target));
} catch (Exception e) {
} catch (JacksonException e) {
Error error = Error.builder()
.messageKey("parser")
.format(new MessageFormat(e.getClass().getName() + ": " + e.getMessage()))
Expand All @@ -74,7 +74,7 @@ public List<Error> validate(File file) throws Exception {
}
}

public void init() throws Exception {
public void init() {
String location = canonical ? LOCATION_CANONICAL : LOCATION;
var model = mapper.readTree(YamlValidator.class.getResourceAsStream(location));
var version = getSpecificationVersion(model).orElse(SpecificationVersion.DRAFT_4);
Expand Down
2 changes: 1 addition & 1 deletion parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@
<neoscada-version>0.4.0</neoscada-version>
<neo4j-version>6.1.0</neo4j-version>
<netty-version>4.2.12.Final</netty-version>
<networknt-json-schema-validator-version>2.0.1</networknt-json-schema-validator-version>
<networknt-json-schema-validator-version>3.0.3</networknt-json-schema-validator-version>
<nimbus-jose-jwt>10.9.1</nimbus-jose-jwt>
<olingo2-version>2.0.13</olingo2-version>
<olingo4-version>5.0.0</olingo4-version>
Expand Down