Skip to content

Commit efb8a48

Browse files
authored
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]>
1 parent a0b6854 commit efb8a48

File tree

9 files changed

+72
-30
lines changed

9 files changed

+72
-30
lines changed

nifi-extension-bundles/nifi-elasticsearch-bundle/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ language governing permissions and limitations under the License. -->
3333
</modules>
3434

3535
<properties>
36-
<elasticsearch.client.version>9.1.5</elasticsearch.client.version>
36+
<elasticsearch.client.version>9.2.0</elasticsearch.client.version>
3737
</properties>
3838

3939
<dependencyManagement>

nifi-extension-bundles/nifi-registry-bundle/nifi-registry-service/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ language governing permissions and limitations under the License. -->
5656
<dependency>
5757
<groupId>com.networknt</groupId>
5858
<artifactId>json-schema-validator</artifactId>
59-
<version>1.5.9</version>
59+
<version>2.0.0</version>
6060
</dependency>
6161
<dependency>
6262
<groupId>org.apache.nifi</groupId>

nifi-extension-bundles/nifi-registry-bundle/nifi-registry-service/src/main/java/org/apache/nifi/schemaregistry/services/StandardJsonSchemaRegistry.java

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
*/
1717
package org.apache.nifi.schemaregistry.services;
1818

19-
import com.networknt.schema.JsonSchemaFactory;
20-
import com.networknt.schema.SpecVersion;
19+
import com.networknt.schema.InputFormat;
20+
import com.networknt.schema.SchemaRegistry;
21+
import com.networknt.schema.SchemaLocation;
22+
import com.networknt.schema.SpecificationVersion;
2123
import org.apache.nifi.annotation.behavior.DynamicProperty;
2224
import org.apache.nifi.annotation.documentation.CapabilityDescription;
2325
import org.apache.nifi.annotation.documentation.Tags;
@@ -63,14 +65,14 @@ public class StandardJsonSchemaRegistry extends AbstractControllerService implem
6365
);
6466

6567
private final ConcurrentMap<String, JsonSchema> jsonSchemas;
66-
private final ConcurrentMap<SchemaVersion, JsonSchemaFactory> schemaFactories;
68+
private final ConcurrentMap<SchemaVersion, SchemaRegistry> schemaRegistries;
6769
private volatile SchemaVersion schemaVersion;
6870

6971
public StandardJsonSchemaRegistry() {
7072
jsonSchemas = new ConcurrentHashMap<>();
71-
schemaFactories = Arrays.stream(SchemaVersion.values())
73+
schemaRegistries = Arrays.stream(SchemaVersion.values())
7274
.collect(Collectors.toConcurrentMap(Function.identity(),
73-
schemaDraftVersion -> JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.fromId(schemaDraftVersion.getUri()).get())));
75+
schemaDraftVersion -> SchemaRegistry.withDefaultDialect(mapToSpecification(schemaDraftVersion))));
7476
schemaVersion = SchemaVersion.valueOf(SCHEMA_VERSION.getDefaultValue());
7577
}
7678

@@ -83,8 +85,8 @@ public void onPropertyModified(final PropertyDescriptor descriptor, final String
8385
} else if (descriptor.isDynamic() && isNotBlank(newValue)) {
8486
try {
8587
final String schemaName = descriptor.getName();
86-
final JsonSchemaFactory jsonSchemaFactory = schemaFactories.get(schemaVersion);
87-
jsonSchemaFactory.getSchema(newValue);
88+
final SchemaRegistry schemaRegistry = schemaRegistries.get(schemaVersion);
89+
schemaRegistry.getSchema(SchemaLocation.DOCUMENT, newValue, InputFormat.JSON);
8890
jsonSchemas.put(schemaName, new JsonSchema(schemaVersion, newValue));
8991
} catch (final Exception e) {
9092
getLogger().debug("Exception thrown when changing value of schema name '{}' from '{}' to '{}'",
@@ -115,8 +117,8 @@ protected Collection<ValidationResult> customValidate(ValidationContext validati
115117
String input = entry.getValue();
116118
if (isNotBlank(input)) {
117119
try {
118-
final JsonSchemaFactory jsonSchemaFactory = schemaFactories.get(schemaVersion);
119-
jsonSchemaFactory.getSchema(input);
120+
final SchemaRegistry schemaRegistry = schemaRegistries.get(schemaVersion);
121+
schemaRegistry.getSchema(SchemaLocation.DOCUMENT, input, InputFormat.JSON);
120122
} catch (Exception e) {
121123
results.add(new ValidationResult.Builder()
122124
.input(input)
@@ -156,4 +158,20 @@ protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String
156158
.expressionLanguageSupported(ExpressionLanguageScope.NONE)
157159
.build();
158160
}
161+
162+
private SpecificationVersion mapToSpecification(final SchemaVersion schemaVersion) {
163+
switch (schemaVersion) {
164+
case DRAFT_4:
165+
return SpecificationVersion.DRAFT_4;
166+
case DRAFT_6:
167+
return SpecificationVersion.DRAFT_6;
168+
case DRAFT_7:
169+
return SpecificationVersion.DRAFT_7;
170+
case DRAFT_2019_09:
171+
return SpecificationVersion.DRAFT_2019_09;
172+
case DRAFT_2020_12:
173+
return SpecificationVersion.DRAFT_2020_12;
174+
}
175+
throw new IllegalArgumentException("Unsupported schema version: " + schemaVersion);
176+
}
159177
}

nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@
407407
<dependency>
408408
<groupId>net.datafaker</groupId>
409409
<artifactId>datafaker</artifactId>
410-
<version>2.5.2</version>
410+
<version>2.5.3</version>
411411
<exclusions>
412412
<!-- Exclude snakeyaml with android qualifier -->
413413
<exclusion>

nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ValidateJson.java

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
import com.fasterxml.jackson.core.JsonParser;
2020
import com.fasterxml.jackson.databind.JsonNode;
2121
import com.fasterxml.jackson.databind.ObjectMapper;
22-
import com.networknt.schema.JsonSchemaFactory;
23-
import com.networknt.schema.SpecVersion;
24-
import com.networknt.schema.ValidationMessage;
22+
import com.networknt.schema.Error;
23+
import com.networknt.schema.Schema;
24+
import com.networknt.schema.SchemaRegistry;
25+
import com.networknt.schema.SpecificationVersion;
2526
import org.apache.nifi.annotation.behavior.InputRequirement;
2627
import org.apache.nifi.annotation.behavior.InputRequirement.Requirement;
2728
import org.apache.nifi.annotation.behavior.Restricted;
@@ -210,14 +211,14 @@ public String getDescription() {
210211

211212
private ObjectMapper mapper;
212213

213-
private final ConcurrentMap<SchemaVersion, JsonSchemaFactory> schemaFactories = Arrays.stream(SchemaVersion.values())
214+
private final ConcurrentMap<SchemaVersion, SchemaRegistry> schemaRegistries = Arrays.stream(SchemaVersion.values())
214215
.collect(
215216
Collectors.toConcurrentMap(
216217
Function.identity(),
217-
schemaDraftVersion -> JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.fromId(schemaDraftVersion.getUri()).get())
218+
schemaDraftVersion -> SchemaRegistry.withDefaultDialect(mapToSpecification(schemaDraftVersion))
218219
)
219220
);
220-
private volatile com.networknt.schema.JsonSchema schema;
221+
private volatile Schema schema;
221222
private volatile JsonSchemaRegistry jsonSchemaRegistry;
222223

223224
@Override
@@ -265,8 +266,8 @@ public void onScheduled(final ProcessContext context) throws IOException {
265266
case SCHEMA_CONTENT_PROPERTY -> {
266267
try (final InputStream inputStream = context.getProperty(SCHEMA_CONTENT).asResource().read()) {
267268
final SchemaVersion schemaVersion = SchemaVersion.valueOf(context.getProperty(SCHEMA_VERSION).getValue());
268-
final JsonSchemaFactory factory = schemaFactories.get(schemaVersion);
269-
schema = factory.getSchema(inputStream);
269+
final SchemaRegistry registry = schemaRegistries.get(schemaVersion);
270+
schema = registry.getSchema(inputStream);
270271
}
271272
}
272273
}
@@ -288,8 +289,8 @@ public void onTrigger(final ProcessContext context, final ProcessSession session
288289
try {
289290
final String schemaName = context.getProperty(SCHEMA_NAME).evaluateAttributeExpressions(flowFile).getValue();
290291
final JsonSchema jsonSchema = jsonSchemaRegistry.retrieveSchema(schemaName);
291-
final JsonSchemaFactory factory = schemaFactories.get(jsonSchema.getSchemaVersion());
292-
schema = factory.getSchema(jsonSchema.getSchemaText());
292+
final SchemaRegistry registry = schemaRegistries.get(jsonSchema.getSchemaVersion());
293+
schema = registry.getSchema(jsonSchema.getSchemaText());
293294
} catch (Exception e) {
294295
getLogger().error("Could not retrieve JSON schema for {}", flowFile, e);
295296
session.getProvenanceReporter().route(flowFile, REL_FAILURE);
@@ -300,7 +301,14 @@ public void onTrigger(final ProcessContext context, final ProcessSession session
300301

301302
try (final InputStream in = session.read(flowFile)) {
302303
final JsonNode node = mapper.readTree(in);
303-
final Set<ValidationMessage> errors = schema.validate(node);
304+
final Schema activeSchema = schema;
305+
if (activeSchema == null) {
306+
getLogger().error("JSON schema not configured for {}", flowFile);
307+
session.getProvenanceReporter().route(flowFile, REL_FAILURE);
308+
session.transfer(flowFile, REL_FAILURE);
309+
return;
310+
}
311+
final List<Error> errors = activeSchema.validate(node);
304312

305313
if (errors.isEmpty()) {
306314
getLogger().debug("JSON {} valid", flowFile);
@@ -324,6 +332,22 @@ private String getPropertyValidateMessage(JsonSchemaStrategy schemaAccessStrateg
324332
return "The '" + schemaAccessStrategy.getValue() + "' Schema Access Strategy requires that the " + property.getDisplayName() + " property be set.";
325333
}
326334

335+
private SpecificationVersion mapToSpecification(final SchemaVersion schemaVersion) {
336+
switch (schemaVersion) {
337+
case DRAFT_4:
338+
return SpecificationVersion.DRAFT_4;
339+
case DRAFT_6:
340+
return SpecificationVersion.DRAFT_6;
341+
case DRAFT_7:
342+
return SpecificationVersion.DRAFT_7;
343+
case DRAFT_2019_09:
344+
return SpecificationVersion.DRAFT_2019_09;
345+
case DRAFT_2020_12:
346+
return SpecificationVersion.DRAFT_2020_12;
347+
}
348+
throw new IllegalArgumentException("Unsupported schema version: " + schemaVersion);
349+
}
350+
327351
private JsonSchemaStrategy getSchemaAccessStrategy(PropertyContext context) {
328352
return context.getProperty(SCHEMA_ACCESS_STRATEGY).asAllowableValue(JsonSchemaStrategy.class);
329353
}

nifi-extension-bundles/nifi-standard-bundle/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@
230230
<dependency>
231231
<groupId>com.networknt</groupId>
232232
<artifactId>json-schema-validator</artifactId>
233-
<version>1.5.9</version>
233+
<version>2.0.0</version>
234234
</dependency>
235235
</dependencies>
236236
</dependencyManagement>

nifi-extension-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,13 @@
130130
<dependency>
131131
<groupId>org.xmlunit</groupId>
132132
<artifactId>xmlunit-matchers</artifactId>
133-
<version>2.10.4</version>
133+
<version>2.11.0</version>
134134
<scope>test</scope>
135135
</dependency>
136136
<dependency>
137137
<groupId>org.xmlunit</groupId>
138138
<artifactId>xmlunit-core</artifactId>
139-
<version>2.10.4</version>
139+
<version>2.11.0</version>
140140
<scope>test</scope>
141141
</dependency>
142142
<dependency>

nifi-registry/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
<properties>
3838
<jakarta.ws.rs-api.version>3.1.0</jakarta.ws.rs-api.version>
3939
<jersey.bom.version>3.1.11</jersey.bom.version>
40-
<spring.boot.version>3.5.6</spring.boot.version>
41-
<flyway.version>11.14.1</flyway.version>
40+
<spring.boot.version>3.5.7</spring.boot.version>
41+
<flyway.version>11.15.0</flyway.version>
4242
<flyway.tests.version>10.0.0</flyway.tests.version>
4343
<swagger.ui.version>3.12.0</swagger.ui.version>
4444
<jgit.version>7.4.0.202509020913-r</jgit.version>
@@ -257,7 +257,7 @@
257257
<plugin>
258258
<groupId>org.apache.maven.plugins</groupId>
259259
<artifactId>maven-war-plugin</artifactId>
260-
<version>3.4.0</version>
260+
<version>3.5.0</version>
261261
</plugin>
262262
<plugin>
263263
<groupId>org.apache.maven.plugins</groupId>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121

122122
<!-- AWS SDK -->
123123
<com.amazonaws.version>1.12.792</com.amazonaws.version>
124-
<software.amazon.awssdk.version>2.36.0</software.amazon.awssdk.version>
124+
<software.amazon.awssdk.version>2.36.2</software.amazon.awssdk.version>
125125

126126
<!-- Apache Commons -->
127127
<org.apache.commons.cli.version>1.10.0</org.apache.commons.cli.version>

0 commit comments

Comments
 (0)