This is an automated email from the ASF dual-hosted git repository.
exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new efb8a48233 NIFI-15143 Bump JSON Schema Validator to 2.0.0, Datafaker
to 2.5.3, Spring Boot to 3.5.7, and others (#10466)
efb8a48233 is described below
commit efb8a48233bb1a1a7cfa6fb36d8b428ba5a5dd48
Author: Pierre Villard <[email protected]>
AuthorDate: Mon Oct 27 17:45:25 2025 +0100
NIFI-15143 Bump JSON Schema Validator to 2.0.0, Datafaker to 2.5.3, Spring
Boot to 3.5.7, and others (#10466)
- Elasticsearch Client from 9.1.5 to 9.2.0 -
https://github.com/elastic/elasticsearch-java/releases
- JSON Schema Validator from 1.5.9 to 2.0.0 -
https://github.com/networknt/json-schema-validator/releases/tag/2.0.0
- Datafaker from 2.5.2 to 2.5.3 -
https://github.com/datafaker-net/datafaker/releases/tag/2.5.3
- XML Unit from 2.10.4 to 2.11.0 -
https://github.com/xmlunit/xmlunit/releases/tag/v2.11.0
- Spring Boot from 3.5.6 to 3.5.7 -
https://github.com/spring-projects/spring-boot/releases/tag/v3.5.7
- FlywayDB from 11.14.1 to 11.15.0 -
https://github.com/flyway/flyway/releases/tag/flyway-11.15.0
- AWS SDK v2 from 2.36.0 to 2.36.2 -
https://github.com/aws/aws-sdk-java-v2/blob/master/CHANGELOG.md
Signed-off-by: David Handermann <[email protected]>
---
.../nifi-elasticsearch-bundle/pom.xml | 2 +-
.../nifi-registry-service/pom.xml | 2 +-
.../services/StandardJsonSchemaRegistry.java | 36 ++++++++++++-----
.../nifi-standard-processors/pom.xml | 2 +-
.../nifi/processors/standard/ValidateJson.java | 46 ++++++++++++++++------
.../nifi-standard-bundle/pom.xml | 2 +-
.../nifi-record-serialization-services/pom.xml | 4 +-
nifi-registry/pom.xml | 6 +--
pom.xml | 2 +-
9 files changed, 72 insertions(+), 30 deletions(-)
diff --git a/nifi-extension-bundles/nifi-elasticsearch-bundle/pom.xml
b/nifi-extension-bundles/nifi-elasticsearch-bundle/pom.xml
index 28fe246e2d..e83faeeda7 100644
--- a/nifi-extension-bundles/nifi-elasticsearch-bundle/pom.xml
+++ b/nifi-extension-bundles/nifi-elasticsearch-bundle/pom.xml
@@ -33,7 +33,7 @@ language governing permissions and limitations under the
License. -->
</modules>
<properties>
- <elasticsearch.client.version>9.1.5</elasticsearch.client.version>
+ <elasticsearch.client.version>9.2.0</elasticsearch.client.version>
</properties>
<dependencyManagement>
diff --git
a/nifi-extension-bundles/nifi-registry-bundle/nifi-registry-service/pom.xml
b/nifi-extension-bundles/nifi-registry-bundle/nifi-registry-service/pom.xml
index 4f4ae71086..4c2e22af87 100644
--- a/nifi-extension-bundles/nifi-registry-bundle/nifi-registry-service/pom.xml
+++ b/nifi-extension-bundles/nifi-registry-bundle/nifi-registry-service/pom.xml
@@ -56,7 +56,7 @@ language governing permissions and limitations under the
License. -->
<dependency>
<groupId>com.networknt</groupId>
<artifactId>json-schema-validator</artifactId>
- <version>1.5.9</version>
+ <version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
diff --git
a/nifi-extension-bundles/nifi-registry-bundle/nifi-registry-service/src/main/java/org/apache/nifi/schemaregistry/services/StandardJsonSchemaRegistry.java
b/nifi-extension-bundles/nifi-registry-bundle/nifi-registry-service/src/main/java/org/apache/nifi/schemaregistry/services/StandardJsonSchemaRegistry.java
index 9a0136fc0d..96801cdc0d 100644
---
a/nifi-extension-bundles/nifi-registry-bundle/nifi-registry-service/src/main/java/org/apache/nifi/schemaregistry/services/StandardJsonSchemaRegistry.java
+++
b/nifi-extension-bundles/nifi-registry-bundle/nifi-registry-service/src/main/java/org/apache/nifi/schemaregistry/services/StandardJsonSchemaRegistry.java
@@ -16,8 +16,10 @@
*/
package org.apache.nifi.schemaregistry.services;
-import com.networknt.schema.JsonSchemaFactory;
-import com.networknt.schema.SpecVersion;
+import com.networknt.schema.InputFormat;
+import com.networknt.schema.SchemaRegistry;
+import com.networknt.schema.SchemaLocation;
+import com.networknt.schema.SpecificationVersion;
import org.apache.nifi.annotation.behavior.DynamicProperty;
import org.apache.nifi.annotation.documentation.CapabilityDescription;
import org.apache.nifi.annotation.documentation.Tags;
@@ -63,14 +65,14 @@ public class StandardJsonSchemaRegistry extends
AbstractControllerService implem
);
private final ConcurrentMap<String, JsonSchema> jsonSchemas;
- private final ConcurrentMap<SchemaVersion, JsonSchemaFactory>
schemaFactories;
+ private final ConcurrentMap<SchemaVersion, SchemaRegistry>
schemaRegistries;
private volatile SchemaVersion schemaVersion;
public StandardJsonSchemaRegistry() {
jsonSchemas = new ConcurrentHashMap<>();
- schemaFactories = Arrays.stream(SchemaVersion.values())
+ schemaRegistries = Arrays.stream(SchemaVersion.values())
.collect(Collectors.toConcurrentMap(Function.identity(),
- schemaDraftVersion ->
JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.fromId(schemaDraftVersion.getUri()).get())));
+ schemaDraftVersion ->
SchemaRegistry.withDefaultDialect(mapToSpecification(schemaDraftVersion))));
schemaVersion =
SchemaVersion.valueOf(SCHEMA_VERSION.getDefaultValue());
}
@@ -83,8 +85,8 @@ public class StandardJsonSchemaRegistry extends
AbstractControllerService implem
} else if (descriptor.isDynamic() && isNotBlank(newValue)) {
try {
final String schemaName = descriptor.getName();
- final JsonSchemaFactory jsonSchemaFactory =
schemaFactories.get(schemaVersion);
- jsonSchemaFactory.getSchema(newValue);
+ final SchemaRegistry schemaRegistry =
schemaRegistries.get(schemaVersion);
+ schemaRegistry.getSchema(SchemaLocation.DOCUMENT, newValue,
InputFormat.JSON);
jsonSchemas.put(schemaName, new JsonSchema(schemaVersion,
newValue));
} catch (final Exception e) {
getLogger().debug("Exception thrown when changing value of
schema name '{}' from '{}' to '{}'",
@@ -115,8 +117,8 @@ public class StandardJsonSchemaRegistry extends
AbstractControllerService implem
String input = entry.getValue();
if (isNotBlank(input)) {
try {
- final JsonSchemaFactory jsonSchemaFactory =
schemaFactories.get(schemaVersion);
- jsonSchemaFactory.getSchema(input);
+ final SchemaRegistry schemaRegistry =
schemaRegistries.get(schemaVersion);
+
schemaRegistry.getSchema(SchemaLocation.DOCUMENT, input, InputFormat.JSON);
} catch (Exception e) {
results.add(new ValidationResult.Builder()
.input(input)
@@ -156,4 +158,20 @@ public class StandardJsonSchemaRegistry extends
AbstractControllerService implem
.expressionLanguageSupported(ExpressionLanguageScope.NONE)
.build();
}
+
+ private SpecificationVersion mapToSpecification(final SchemaVersion
schemaVersion) {
+ switch (schemaVersion) {
+ case DRAFT_4:
+ return SpecificationVersion.DRAFT_4;
+ case DRAFT_6:
+ return SpecificationVersion.DRAFT_6;
+ case DRAFT_7:
+ return SpecificationVersion.DRAFT_7;
+ case DRAFT_2019_09:
+ return SpecificationVersion.DRAFT_2019_09;
+ case DRAFT_2020_12:
+ return SpecificationVersion.DRAFT_2020_12;
+ }
+ throw new IllegalArgumentException("Unsupported schema version: " +
schemaVersion);
+ }
}
diff --git
a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/pom.xml
b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/pom.xml
index 7517e6f1aa..603f2ee667 100644
---
a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/pom.xml
+++
b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/pom.xml
@@ -407,7 +407,7 @@
<dependency>
<groupId>net.datafaker</groupId>
<artifactId>datafaker</artifactId>
- <version>2.5.2</version>
+ <version>2.5.3</version>
<exclusions>
<!-- Exclude snakeyaml with android qualifier -->
<exclusion>
diff --git
a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ValidateJson.java
b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ValidateJson.java
index b6d0cde457..91584b68d1 100644
---
a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ValidateJson.java
+++
b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ValidateJson.java
@@ -19,9 +19,10 @@ package org.apache.nifi.processors.standard;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.networknt.schema.JsonSchemaFactory;
-import com.networknt.schema.SpecVersion;
-import com.networknt.schema.ValidationMessage;
+import com.networknt.schema.Error;
+import com.networknt.schema.Schema;
+import com.networknt.schema.SchemaRegistry;
+import com.networknt.schema.SpecificationVersion;
import org.apache.nifi.annotation.behavior.InputRequirement;
import org.apache.nifi.annotation.behavior.InputRequirement.Requirement;
import org.apache.nifi.annotation.behavior.Restricted;
@@ -210,14 +211,14 @@ public class ValidateJson extends AbstractProcessor {
private ObjectMapper mapper;
- private final ConcurrentMap<SchemaVersion, JsonSchemaFactory>
schemaFactories = Arrays.stream(SchemaVersion.values())
+ private final ConcurrentMap<SchemaVersion, SchemaRegistry>
schemaRegistries = Arrays.stream(SchemaVersion.values())
.collect(
Collectors.toConcurrentMap(
Function.identity(),
- schemaDraftVersion ->
JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.fromId(schemaDraftVersion.getUri()).get())
+ schemaDraftVersion ->
SchemaRegistry.withDefaultDialect(mapToSpecification(schemaDraftVersion))
)
);
- private volatile com.networknt.schema.JsonSchema schema;
+ private volatile Schema schema;
private volatile JsonSchemaRegistry jsonSchemaRegistry;
@Override
@@ -265,8 +266,8 @@ public class ValidateJson extends AbstractProcessor {
case SCHEMA_CONTENT_PROPERTY -> {
try (final InputStream inputStream =
context.getProperty(SCHEMA_CONTENT).asResource().read()) {
final SchemaVersion schemaVersion =
SchemaVersion.valueOf(context.getProperty(SCHEMA_VERSION).getValue());
- final JsonSchemaFactory factory =
schemaFactories.get(schemaVersion);
- schema = factory.getSchema(inputStream);
+ final SchemaRegistry registry =
schemaRegistries.get(schemaVersion);
+ schema = registry.getSchema(inputStream);
}
}
}
@@ -288,8 +289,8 @@ public class ValidateJson extends AbstractProcessor {
try {
final String schemaName =
context.getProperty(SCHEMA_NAME).evaluateAttributeExpressions(flowFile).getValue();
final JsonSchema jsonSchema =
jsonSchemaRegistry.retrieveSchema(schemaName);
- final JsonSchemaFactory factory =
schemaFactories.get(jsonSchema.getSchemaVersion());
- schema = factory.getSchema(jsonSchema.getSchemaText());
+ final SchemaRegistry registry =
schemaRegistries.get(jsonSchema.getSchemaVersion());
+ schema = registry.getSchema(jsonSchema.getSchemaText());
} catch (Exception e) {
getLogger().error("Could not retrieve JSON schema for {}",
flowFile, e);
session.getProvenanceReporter().route(flowFile, REL_FAILURE);
@@ -300,7 +301,14 @@ public class ValidateJson extends AbstractProcessor {
try (final InputStream in = session.read(flowFile)) {
final JsonNode node = mapper.readTree(in);
- final Set<ValidationMessage> errors = schema.validate(node);
+ final Schema activeSchema = schema;
+ if (activeSchema == null) {
+ getLogger().error("JSON schema not configured for {}",
flowFile);
+ session.getProvenanceReporter().route(flowFile, REL_FAILURE);
+ session.transfer(flowFile, REL_FAILURE);
+ return;
+ }
+ final List<Error> errors = activeSchema.validate(node);
if (errors.isEmpty()) {
getLogger().debug("JSON {} valid", flowFile);
@@ -324,6 +332,22 @@ public class ValidateJson extends AbstractProcessor {
return "The '" + schemaAccessStrategy.getValue() + "' Schema Access
Strategy requires that the " + property.getDisplayName() + " property be set.";
}
+ private SpecificationVersion mapToSpecification(final SchemaVersion
schemaVersion) {
+ switch (schemaVersion) {
+ case DRAFT_4:
+ return SpecificationVersion.DRAFT_4;
+ case DRAFT_6:
+ return SpecificationVersion.DRAFT_6;
+ case DRAFT_7:
+ return SpecificationVersion.DRAFT_7;
+ case DRAFT_2019_09:
+ return SpecificationVersion.DRAFT_2019_09;
+ case DRAFT_2020_12:
+ return SpecificationVersion.DRAFT_2020_12;
+ }
+ throw new IllegalArgumentException("Unsupported schema version: " +
schemaVersion);
+ }
+
private JsonSchemaStrategy getSchemaAccessStrategy(PropertyContext
context) {
return
context.getProperty(SCHEMA_ACCESS_STRATEGY).asAllowableValue(JsonSchemaStrategy.class);
}
diff --git a/nifi-extension-bundles/nifi-standard-bundle/pom.xml
b/nifi-extension-bundles/nifi-standard-bundle/pom.xml
index acb9d69206..99646c72aa 100644
--- a/nifi-extension-bundles/nifi-standard-bundle/pom.xml
+++ b/nifi-extension-bundles/nifi-standard-bundle/pom.xml
@@ -230,7 +230,7 @@
<dependency>
<groupId>com.networknt</groupId>
<artifactId>json-schema-validator</artifactId>
- <version>1.5.9</version>
+ <version>2.0.0</version>
</dependency>
</dependencies>
</dependencyManagement>
diff --git
a/nifi-extension-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/pom.xml
b/nifi-extension-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/pom.xml
index ea3ad89266..c080bc9393 100755
---
a/nifi-extension-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/pom.xml
+++
b/nifi-extension-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/pom.xml
@@ -130,13 +130,13 @@
<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-matchers</artifactId>
- <version>2.10.4</version>
+ <version>2.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-core</artifactId>
- <version>2.10.4</version>
+ <version>2.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/nifi-registry/pom.xml b/nifi-registry/pom.xml
index 104d17fd91..2a16ec40dc 100644
--- a/nifi-registry/pom.xml
+++ b/nifi-registry/pom.xml
@@ -37,8 +37,8 @@
<properties>
<jakarta.ws.rs-api.version>3.1.0</jakarta.ws.rs-api.version>
<jersey.bom.version>3.1.11</jersey.bom.version>
- <spring.boot.version>3.5.6</spring.boot.version>
- <flyway.version>11.14.1</flyway.version>
+ <spring.boot.version>3.5.7</spring.boot.version>
+ <flyway.version>11.15.0</flyway.version>
<flyway.tests.version>10.0.0</flyway.tests.version>
<swagger.ui.version>3.12.0</swagger.ui.version>
<jgit.version>7.4.0.202509020913-r</jgit.version>
@@ -257,7 +257,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
- <version>3.4.0</version>
+ <version>3.5.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
diff --git a/pom.xml b/pom.xml
index e9e8535e79..357560125c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -121,7 +121,7 @@
<!-- AWS SDK -->
<com.amazonaws.version>1.12.792</com.amazonaws.version>
- <software.amazon.awssdk.version>2.36.0</software.amazon.awssdk.version>
+ <software.amazon.awssdk.version>2.36.2</software.amazon.awssdk.version>
<!-- Apache Commons -->
<org.apache.commons.cli.version>1.10.0</org.apache.commons.cli.version>