Skip to content

Commit c485230

Browse files
authored
Upgrade to Jackson 3 and JDK 17 (#1219)
1 parent ad0f41b commit c485230

203 files changed

Lines changed: 772 additions & 746 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
java: [ 8, 11, 17, 21 ]
16+
java: [ 17, 21, 25 ]
1717
name: Java ${{ matrix.java }}
1818
steps:
1919
- uses: actions/checkout@v4

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,17 +421,17 @@ JsonLocation minLengthInstanceNodeTokenLocation = JsonNodes.tokenStreamLocationO
421421
JsonLocation minLengthSchemaNodeTokenLocation = JsonNodes.tokenStreamLocationOf(minLength.getSchemaNode());
422422

423423
assertEquals("format", format.getKeyword());
424-
assertEquals("date", format.getSchemaNode().asText());
424+
assertEquals("date", format.getSchemaNode().asString());
425425
assertEquals(5, formatSchemaNodeTokenLocation.getLineNr());
426426
assertEquals(17, formatSchemaNodeTokenLocation.getColumnNr());
427-
assertEquals("1", format.getInstanceNode().asText());
427+
assertEquals("1", format.getInstanceNode().asString());
428428
assertEquals(2, formatInstanceNodeTokenLocation.getLineNr());
429429
assertEquals(16, formatInstanceNodeTokenLocation.getColumnNr());
430430
assertEquals("minLength", minLength.getKeyword());
431-
assertEquals("6", minLength.getSchemaNode().asText());
431+
assertEquals("6", minLength.getSchemaNode().asString());
432432
assertEquals(6, minLengthSchemaNodeTokenLocation.getLineNr());
433433
assertEquals(20, minLengthSchemaNodeTokenLocation.getColumnNr());
434-
assertEquals("1", minLength.getInstanceNode().asText());
434+
assertEquals("1", minLength.getInstanceNode().asString());
435435
assertEquals(2, minLengthInstanceNodeTokenLocation.getLineNr());
436436
assertEquals(16, minLengthInstanceNodeTokenLocation.getColumnNr());
437437
assertEquals(16, minLengthInstanceNodeTokenLocation.getColumnNr());

doc/custom-dialect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class EqualsValidator extends BaseKeywordValidator {
3535
@Override
3636
public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode,
3737
NodePath instanceLocation) {
38-
if (!node.asText().equals(value)) {
38+
if (!node.asString().equals(value)) {
3939
executionContext.addError(error().message("must be equal to ''{0}''")
4040
.arguments(value)
4141
.instanceLocation(instanceLocation).instanceNode(node).evaluationPath(executionContext.getEvaluationPath()).build());

doc/upgrading.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ This library can contain breaking changes in `minor` version releases.
44

55
This contains information on the notable or breaking changes in each version.
66

7+
### 3.0.0
8+
9+
| Compatibility | Version |
10+
| ------------- | --------- |
11+
| Java | Java 17 |
12+
| Jackson | Jackson 3 |
13+
14+
#### Major Changes
15+
16+
- Change to use Jackson 3 for which Java 17 is now required.
17+
718
### 2.0.0
819

920
| Compatibility | Version |

doc/walkers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ assertEquals("", propertyKeywords.get(0).getInstanceLocation().toString());
9595
assertEquals("/properties",
9696
propertyKeywords.get(0).getEvaluationPath().append(propertyKeywords.get(0).getKeyword()).toString());
9797
assertEquals("/tags/0", propertyKeywords.get(1).getInstanceLocation().toString());
98-
assertEquals("image", propertyKeywords.get(1).getInstanceNode().get("name").asText());
98+
assertEquals("image", propertyKeywords.get(1).getInstanceNode().get("name").asString());
9999
assertEquals("/properties/tags/items/$ref", propertyKeywords.get(1).getEvaluationPath().toString());
100100
assertEquals("/properties/tags/items/$ref/properties",
101101
propertyKeywords.get(1).getEvaluationPath().append(propertyKeywords.get(1).getKeyword()).toString());
102102
assertEquals("/tags/1", propertyKeywords.get(2).getInstanceLocation().toString());
103103
assertEquals("/properties/tags/items/$ref/properties",
104104
propertyKeywords.get(2).getEvaluationPath().append(propertyKeywords.get(2).getKeyword()).toString());
105-
assertEquals("link", propertyKeywords.get(2).getInstanceNode().get("name").asText());
105+
assertEquals("link", propertyKeywords.get(2).getInstanceNode().get("name").asString());
106106
```
107107

108108
### Applying Defaults

pom.xml

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
<groupId>com.networknt</groupId>
2525
<artifactId>json-schema-validator</artifactId>
26-
<version>2.0.1</version>
26+
<version>3.0.0-SNAPSHOT</version>
2727
<packaging>bundle</packaging>
2828
<name>JsonSchemaValidator</name>
2929
<description>A json schema validator that supports draft v4, v6, v7, v2019-09 and v2020-12</description>
@@ -68,25 +68,25 @@
6868
</distributionManagement>
6969

7070
<properties>
71-
<java.testversion>1.8</java.testversion>
72-
<java.version>1.8</java.version>
71+
<java.testversion>17</java.testversion>
72+
<java.version>17</java.version>
7373
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
7474

7575
<version.itu>1.14.0</version.itu>
76-
<version.jackson>2.18.3</version.jackson>
76+
<version.jackson>3.0.3</version.jackson>
7777
<version.joni>2.2.6</version.joni>
78-
<version.logback>1.3.14</version.logback> <!-- 1.4.x and above is not Java 8 compatible -->
78+
<version.logback>1.5.22</version.logback>
7979
<version.slf4j>2.0.17</version.slf4j>
80-
<version.graaljs>21.3.10</version.graaljs> <!-- 22.x and above is not Java 8 compatible -->
80+
<version.graaljs>25.0.1</version.graaljs>
8181
<version.hamcrest>3.0</version.hamcrest>
82-
<version.junit>5.11.3</version.junit>
83-
<version.jacoco-maven-plugin>0.8.12</version.jacoco-maven-plugin>
84-
<version.maven-compiler-plugin>3.13.0</version.maven-compiler-plugin>
85-
<version.maven-bundle-plugin>5.1.9</version.maven-bundle-plugin>
86-
<version.maven-javadoc-plugin>3.6.3</version.maven-javadoc-plugin>
87-
<version.maven-source-plugin>3.2.1</version.maven-source-plugin> <!-- 3.3.0 and above is not Java 8 compatible -->
88-
<version.maven-surefire-junit5-tree-reporter>1.3.0</version.maven-surefire-junit5-tree-reporter>
89-
<version.maven-surefire-plugin>3.5.1</version.maven-surefire-plugin>
82+
<version.junit>6.0.1</version.junit>
83+
<version.jacoco-maven-plugin>0.8.14</version.jacoco-maven-plugin>
84+
<version.maven-compiler-plugin>3.14.1</version.maven-compiler-plugin>
85+
<version.maven-bundle-plugin>6.0.0</version.maven-bundle-plugin>
86+
<version.maven-javadoc-plugin>3.12.0</version.maven-javadoc-plugin>
87+
<version.maven-source-plugin>3.4.0</version.maven-source-plugin> <!-- 3.3.0 and above is not Java 8 compatible -->
88+
<version.maven-surefire-junit5-tree-reporter>1.5.1</version.maven-surefire-junit5-tree-reporter>
89+
<version.maven-surefire-plugin>3.5.4</version.maven-surefire-plugin>
9090
<version.moditect-maven-plugin>1.2.2.Final</version.moditect-maven-plugin>
9191
<version.nexus-staging-maven>1.7.0</version.nexus-staging-maven>
9292
<version.maven-gpg>3.2.7</version.maven-gpg>
@@ -112,13 +112,13 @@
112112
</dependency>
113113

114114
<dependency>
115-
<groupId>com.fasterxml.jackson.core</groupId>
115+
<groupId>tools.jackson.core</groupId>
116116
<artifactId>jackson-databind</artifactId>
117117
<version>${version.jackson}</version>
118118
</dependency>
119119

120120
<dependency>
121-
<groupId>com.fasterxml.jackson.dataformat</groupId>
121+
<groupId>tools.jackson.dataformat</groupId>
122122
<artifactId>jackson-dataformat-yaml</artifactId>
123123
<version>${version.jackson}</version>
124124
</dependency>
@@ -143,7 +143,16 @@
143143
<!-- Used to validate ECMA 262 regular expressions -->
144144
<!-- Approximately 50 MB in dependencies -->
145145
<groupId>org.graalvm.js</groupId>
146-
<artifactId>js</artifactId>
146+
<artifactId>js-language</artifactId>
147+
<version>${version.graaljs}</version>
148+
<optional>true</optional>
149+
</dependency>
150+
151+
<dependency>
152+
<!-- Used to validate ECMA 262 regular expressions -->
153+
<!-- Approximately 50 MB in dependencies -->
154+
<groupId>org.graalvm.truffle</groupId>
155+
<artifactId>truffle-runtime</artifactId>
147156
<version>${version.graaljs}</version>
148157
<optional>true</optional>
149158
</dependency>
@@ -459,7 +468,7 @@
459468
</exports>
460469
<requires>
461470
static com.ethlo.time;
462-
static com.fasterxml.jackson.dataformat.yaml;
471+
static tools.jackson.dataformat.yaml;
463472
static org.jruby.jcodings;
464473
static org.jruby.joni;
465474
static org.graalvm.sdk;

src/main/java/com/networknt/schema/Error.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
import com.fasterxml.jackson.annotation.JsonInclude;
2121
import com.fasterxml.jackson.annotation.JsonInclude.Include;
2222
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
23-
import com.fasterxml.jackson.databind.JsonNode;
24-
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
25-
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
23+
import tools.jackson.databind.JsonNode;
24+
import tools.jackson.databind.annotation.JsonSerialize;
25+
import tools.jackson.databind.ser.std.ToStringSerializer;
2626
import com.networknt.schema.i18n.MessageFormatter;
2727
import com.networknt.schema.path.NodePath;
2828
import com.networknt.schema.utils.CachingSupplier;
@@ -42,7 +42,7 @@
4242
* "https://github.com/json-schema-org/json-schema-spec/blob/main/specs/output/jsonschema-validation-output-machines.md">JSON
4343
* Schema</a>
4444
*/
45-
@JsonIgnoreProperties({ "messageSupplier", "schemaNode", "instanceNode", "valid" })
45+
@JsonIgnoreProperties({ "messageSupplier", "schemaNode", "instanceNode" })
4646
@JsonPropertyOrder({ "keyword", "instanceLocation", "message", "evaluationPath", "schemaLocation",
4747
"messageKey", "arguments", "details" })
4848
@JsonInclude(Include.NON_NULL)
@@ -176,10 +176,6 @@ public String getMessageKey() {
176176
return messageKey;
177177
}
178178

179-
public boolean isValid() {
180-
return messageSupplier != null;
181-
}
182-
183179
@Override
184180
public String toString() {
185181
StringBuilder builder = new StringBuilder();

src/main/java/com/networknt/schema/ErrorMessages.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import java.util.LinkedHashMap;
55
import java.util.Map;
66

7-
import com.fasterxml.jackson.databind.JsonNode;
7+
import tools.jackson.databind.JsonNode;
88

99
/**
1010
* ErrorMessages.
@@ -24,12 +24,12 @@ public static Map<String, String> getErrorMessage(Schema parentSchema, String er
2424
if (message != null) {
2525
JsonNode messageNode = message.get(keyword);
2626
if (messageNode != null) {
27-
if (messageNode.isTextual()) {
28-
return Collections.singletonMap("", messageNode.asText());
27+
if (messageNode.isString()) {
28+
return Collections.singletonMap("", messageNode.asString());
2929
} else if (messageNode.isObject()) {
3030
Map<String, String> result = new LinkedHashMap<>();
31-
messageNode.fields()
32-
.forEachRemaining(entry -> result.put(entry.getKey(), entry.getValue().textValue()));
31+
messageNode.properties().iterator()
32+
.forEachRemaining(entry -> result.put(entry.getKey(), entry.getValue().asString()));
3333
if (!result.isEmpty()) {
3434
return result;
3535
}

src/main/java/com/networknt/schema/Schema.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import java.util.Objects;
3333
import java.util.function.Consumer;
3434

35-
import com.fasterxml.jackson.databind.JsonNode;
35+
import tools.jackson.databind.JsonNode;
3636
import com.networknt.schema.keyword.KeywordValidator;
3737
import com.networknt.schema.keyword.TypeValidator;
3838
import com.networknt.schema.path.NodePath;
@@ -107,11 +107,11 @@ private static Schema obtainSubSchemaNode(final JsonNode schemaNode, final Schem
107107
return null;
108108
}
109109

110-
final String text = node.textValue();
110+
final String text = node.asString();
111111
if (text == null) {
112112
return null;
113113
}
114-
final SchemaLocation schemaLocation = SchemaLocation.of(node.textValue());
114+
final SchemaLocation schemaLocation = SchemaLocation.of(node.asString());
115115
return schemaContext.getSchemaRegistry().getSchema(schemaLocation);
116116
}
117117
public static class JsonNodePathLegacy {
@@ -519,7 +519,7 @@ private List<KeywordValidator> read(JsonNode schemaNode) {
519519
} else {
520520
KeywordValidator refValidator = null;
521521

522-
Iterator<Entry<String, JsonNode>> iterator = schemaNode.fields();
522+
Iterator<Entry<String, JsonNode>> iterator = schemaNode.properties().iterator();
523523
validators = new ArrayList<>(schemaNode.size());
524524
while (iterator.hasNext()) {
525525
Entry<String, JsonNode> entry = iterator.next();

src/main/java/com/networknt/schema/SchemaContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import java.util.concurrent.ConcurrentHashMap;
2020
import java.util.concurrent.ConcurrentMap;
2121

22-
import com.fasterxml.jackson.databind.JsonNode;
22+
import tools.jackson.databind.JsonNode;
2323
import com.networknt.schema.dialect.Dialect;
2424
import com.networknt.schema.keyword.KeywordValidator;
2525

0 commit comments

Comments
 (0)