Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump the depended Jackson version to 2.15.3 #37

Merged
merged 2 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ jobs:
strategy:
fail-fast: false
matrix:
jacksonVersion: [ "2.6.7", "2.7.9", "2.8.11", "2.9.10", "2.10.5", "2.11.4", "2.12.7", "2.13.5", "2.14.3", "2.15.2" ]
jacksonVersion: [ "2.15.3" ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up OpenJDK 8
uses: actions/setup-java@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
hash-master: ${{ steps.hash-master.outputs.hash-master }}
hash-main: ${{ steps.hash-main.outputs.hash-main }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: hash-master
Expand All @@ -30,7 +30,7 @@ jobs:
if: needs.diff.outputs.hash-master != needs.diff.outputs.hash-main
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checkout master
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
hash-master: ${{ steps.hash-master.outputs.hash-master }}
hash-main: ${{ steps.hash-main.outputs.hash-main }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: hash-master
Expand All @@ -30,7 +30,7 @@ jobs:
if: needs.diff.outputs.hash-master != needs.diff.outputs.hash-main
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checkout main
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up OpenJDK 8
uses: actions/setup-java@v3
with:
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {

ext {
if (!project.hasProperty("jacksonVersionForJacksonTest")) {
jacksonVersionForJacksonTest = "2.6.7"
jacksonVersionForJacksonTest = "2.15.3"
}
}

Expand Down Expand Up @@ -44,7 +44,7 @@ dependencies {
compileOnly "org.msgpack:msgpack-core:0.8.24"

// Dependencies should be "api" so that their scope would be "compile" in "pom.xml".
api platform("com.fasterxml.jackson:jackson-bom:2.6.7")
api platform("com.fasterxml.jackson:jackson-bom:2.15.3")
api "com.fasterxml.jackson.core:jackson-core"

testImplementation "org.embulk:embulk-spi:0.11"
Expand All @@ -68,7 +68,7 @@ javadoc {
overview = "src/main/html/overview.html"
links "https://docs.oracle.com/javase/8/docs/api/"
links "https://dev.embulk.org/embulk-spi/0.11/javadoc/"
links "https://www.javadoc.io/doc/com.fasterxml.jackson.core/jackson-core/2.6.7/"
links "https://www.javadoc.io/doc/com.fasterxml.jackson.core/jackson-core/2.15.3/"
links "https://javadoc.io/doc/org.msgpack/msgpack-core/0.8.24/"
}
}
Expand Down
4 changes: 2 additions & 2 deletions gradle.lockfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
com.fasterxml.jackson.core:jackson-core:2.6.7=compileClasspath,runtimeClasspath
com.fasterxml.jackson:jackson-bom:2.6.7=compileClasspath,runtimeClasspath
com.fasterxml.jackson.core:jackson-core:2.15.3=compileClasspath,runtimeClasspath
com.fasterxml.jackson:jackson-bom:2.15.3=compileClasspath,runtimeClasspath
org.embulk:embulk-spi:0.11=compileClasspath
org.msgpack:msgpack-core:0.8.24=compileClasspath
org.slf4j:slf4j-api:2.0.7=compileClasspath
Expand Down
18 changes: 16 additions & 2 deletions src/main/java/org/embulk/util/json/JsonValueParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import com.fasterxml.jackson.core.JsonPointer;
import com.fasterxml.jackson.core.filter.FilteringParserDelegate;
import com.fasterxml.jackson.core.filter.JsonPointerBasedFilter;
import com.fasterxml.jackson.core.filter.TokenFilter;
import com.fasterxml.jackson.core.json.PackageVersion;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -177,15 +179,15 @@ private com.fasterxml.jackson.core.JsonParser extendJacksonParser(final com.fast
parser = new FilteringParserDelegate(
parser,
new JsonPointerBasedFilter(this.root),
false, // TODO: Use com.fasterxml.jackson.core.filter.TokenFilter.Inclusion since Jackson 2.12.
TokenFilter.Inclusion.ONLY_INCLUDE_ALL,
true // Allow multiple matches
);
}
if (this.depthToFlattenJsonArrays > 0) {
parser = new FilteringParserDelegate(
parser,
new FlattenJsonArrayFilter(this.depthToFlattenJsonArrays),
false, // TODO: Use com.fasterxml.jackson.core.filter.TokenFilter.Inclusion since Jackson 2.12.
TokenFilter.Inclusion.ONLY_INCLUDE_ALL,
true // Allow multiple matches
);
}
Expand Down Expand Up @@ -231,6 +233,7 @@ public static Builder builder() {
* @return the new builder
*/
public static Builder builder(final JsonFactory jsonFactory) {
assertJacksonVersion();
return new Builder(jsonFactory);
}

Expand Down Expand Up @@ -266,6 +269,17 @@ public final void close() throws IOException {
this.jacksonParser.close();
}

private static void assertJacksonVersion() {
if (PackageVersion.VERSION.getMajorVersion() != 2) {
throw new UnsupportedOperationException("embulk-util-json is not used with Jackson 2.");
}

final int minor = PackageVersion.VERSION.getMinorVersion();
if (minor < 14 || (minor == 15 && PackageVersion.VERSION.getPatchLevel() <= 2)) {
throw new UnsupportedOperationException("embulk-util-json is not used with Jackson 2.15.3 or later.");
}
}

private final com.fasterxml.jackson.core.JsonParser jacksonParser;
private final InternalJsonValueReader valueReader;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.core.filter.FilteringParserDelegate;
import com.fasterxml.jackson.core.filter.TokenFilter;
import java.io.IOException;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -105,7 +106,7 @@ private static com.fasterxml.jackson.core.JsonParser createFilteredParser(
return new FilteringParserDelegate(
factory.createParser(json),
new FlattenJsonArrayFilter(depth),
false, // TODO: Use com.fasterxml.jackson.core.filter.TokenFilter.Inclusion since Jackson 2.12.
TokenFilter.Inclusion.ONLY_INCLUDE_ALL,
true // Allow multiple matches
);
}
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/org/embulk/util/json/TestJacksonFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.core.filter.FilteringParserDelegate;
import com.fasterxml.jackson.core.filter.JsonPointerBasedFilter;
import com.fasterxml.jackson.core.filter.TokenFilter;
import com.fasterxml.jackson.core.json.PackageVersion;
import java.io.IOException;
import org.junit.jupiter.api.BeforeAll;
Expand Down Expand Up @@ -65,7 +66,7 @@ private static com.fasterxml.jackson.core.JsonParser createFilteredParser(
return new FilteringParserDelegate(
factory.createParser(json),
new JsonPointerBasedFilter(jsonPointer),
false, // TODO: Use com.fasterxml.jackson.core.filter.TokenFilter.Inclusion since Jackson 2.12.
TokenFilter.Inclusion.ONLY_INCLUDE_ALL,
true // Allow multiple matches
);
}
Expand Down
44 changes: 6 additions & 38 deletions src/test/java/org/embulk/util/json/TestJacksonJsonPointer.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ public class TestJacksonJsonPointer {
public void testEmpty() throws IOException {
final JsonPointer empty = JsonPointer.compile("");
assertEquals("", empty.toString());
if (isBefore2_14_0()) {
assertEquals("", empty.getMatchingProperty());
} else {
assertEquals(null, empty.getMatchingProperty());
}
assertEquals(null, empty.getMatchingProperty());
assertTrue(empty.getMatchingIndex() < 0);
assertEquals(JsonPointer.compile(""), empty);
assertNotEquals(JsonPointer.compile("/"), empty);
Expand All @@ -57,11 +53,7 @@ public void testRoot() throws IOException {

final JsonPointer tail = root.tail();
assertEquals("", tail.toString());
if (isBefore2_14_0()) {
assertEquals("", tail.getMatchingProperty());
} else {
assertEquals(null, tail.getMatchingProperty());
}
assertEquals(null, tail.getMatchingProperty());
assertTrue(tail.getMatchingIndex() < 0);
assertEquals(JsonPointer.compile(""), tail);
assertNotEquals(JsonPointer.compile("/"), tail);
Expand Down Expand Up @@ -91,11 +83,7 @@ public void testRootDuplicated() throws IOException {

final JsonPointer tail2 = tail1.tail();
assertEquals("", tail2.toString());
if (isBefore2_14_0()) {
assertEquals("", tail2.getMatchingProperty());
} else {
assertEquals(null, tail2.getMatchingProperty());
}
assertEquals(null, tail2.getMatchingProperty());
assertTrue(tail2.getMatchingIndex() < 0);
assertEquals(JsonPointer.compile(""), tail2);
assertNotEquals(JsonPointer.compile("/"), tail2);
Expand All @@ -116,11 +104,7 @@ public void testSingleProperty() throws IOException {

final JsonPointer tail = root.tail();
assertEquals("", tail.toString());
if (isBefore2_14_0()) {
assertEquals("", tail.getMatchingProperty());
} else {
assertEquals(null, tail.getMatchingProperty());
}
assertEquals(null, tail.getMatchingProperty());
assertTrue(tail.getMatchingIndex() < 0);
assertEquals(JsonPointer.compile(""), tail);
assertNotEquals(JsonPointer.compile("/"), tail);
Expand All @@ -141,11 +125,7 @@ public void testSingleIndex() throws IOException {

final JsonPointer tail = root.tail();
assertEquals("", tail.toString());
if (isBefore2_14_0()) {
assertEquals("", tail.getMatchingProperty());
} else {
assertEquals(null, tail.getMatchingProperty());
}
assertEquals(null, tail.getMatchingProperty());
assertTrue(tail.getMatchingIndex() < 0);
assertEquals(JsonPointer.compile(""), tail);
assertNotEquals(JsonPointer.compile("/"), tail);
Expand Down Expand Up @@ -185,11 +165,7 @@ public void testMultipleProperties() throws IOException {

final JsonPointer tail3 = tail2.tail();
assertEquals("", tail3.toString());
if (isBefore2_14_0()) {
assertEquals("", tail3.getMatchingProperty());
} else {
assertEquals(null, tail3.getMatchingProperty());
}
assertEquals(null, tail3.getMatchingProperty());
assertTrue(tail3.getMatchingIndex() < 0);
assertEquals(JsonPointer.compile(""), tail3);
assertNotEquals(JsonPointer.compile("/"), tail3);
Expand All @@ -203,12 +179,4 @@ public void testMultipleProperties() throws IOException {
static void printJacksonVersion() {
System.out.println("Tested with Jackson: " + PackageVersion.VERSION.toString());
}

// The behavior of JsonPointer.compile("").tail() is different from Jackson 2.14.0.
//
// https://github.com/FasterXML/jackson-core/issues/788
// https://github.com/FasterXML/jackson-core/commit/b0f6eb9bb2d2d829efb19020e7df4d732066f8cd
private static boolean isBefore2_14_0() {
return PackageVersion.VERSION.getMajorVersion() <= 2 && PackageVersion.VERSION.getMinorVersion() <= 13;
}
}