diff --git a/.travis.yml b/.travis.yml index 87d17607..581a2ae9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: java jdk: - - openjdk8 - - openjdk11 + - openjdk17 install: {} script: - ./gradlew assemble check diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index daeb6767..748e5678 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -1,3 +1,7 @@ +## Kovács Zoltán (https://github.com/kz282) + +* Upgrade to Jackson 3.0 + ## Ryan Lopopolo (https://github.com/lopopolo) * Fix bug in JSON Patch add where target path is not a container node diff --git a/README.md b/README.md index 42af29b0..47793928 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ only. This is an implementation of [RFC 6902 (JSON Patch)](http://tools.ietf.org/html/rfc6902) and [RFC 7386 (JSON Merge Patch)](http://tools.ietf.org/html/rfc7386) written in Java, -which uses [Jackson](https://github.com/FasterXML/jackson-databind) (2.2.x) at its core. +which uses [Jackson](https://github.com/FasterXML/jackson-databind) (3.0.x) at its core. Its features are: @@ -26,7 +26,7 @@ Its features are: ## Versions -The current version is **1.13**. See file `RELEASE-NOTES.md` for details of releases before 1.11. +The current version is **2.0**. See file `RELEASE-NOTES.md` for details of releases before 1.11. ## Using it in your project diff --git a/build.gradle b/build.gradle index 8ffa1a34..11e24c40 100644 --- a/build.gradle +++ b/build.gradle @@ -17,233 +17,125 @@ * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt */ -buildscript { - repositories { - mavenCentral() - maven { - url "http://repo.springsource.org/plugins-release"; - } - } - dependencies { - classpath 'biz.aQute.bnd:biz.aQute.bnd.gradle:4.2.0' - classpath(group: "org.springframework.build.gradle", name: "propdeps-plugin", version: "0.0.7"); - } -}; - plugins { - id("net.ltgt.errorprone") version "0.8.1" apply false -} - -configure(allprojects) { - apply(plugin: "propdeps"); - apply(plugin: "propdeps-maven"); - apply(plugin: "propdeps-idea"); - apply(plugin: "propdeps-eclipse"); + id "java-library" + id "maven-publish" + id "signing" + id "idea" + id "eclipse" + id "com.github.ben-manes.versions" version "0.51.0" } -apply(plugin: "java"); -apply(plugin: "maven"); -apply(plugin: "signing"); -apply(plugin: "biz.aQute.bnd.builder"); -apply(plugin: "idea"); -apply(plugin: "eclipse"); -apply(plugin: "net.ltgt.errorprone"); - -apply(from: "project.gradle"); +group = "com.github.java-json-tools" +version = "1.14-SNAPSHOT" +description = "JSON Patch (RFC 6902) and JSON Merge Patch (RFC 7386) implementation in Java" -group = "com.github.java-json-tools"; - -ext.forRelease = !version.endsWith("-SNAPSHOT"); +java { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + withSourcesJar() + withJavadocJar() +} -/* - * Repositories to use - */ repositories { - mavenCentral(); - if (!forRelease) { - maven { - url "https://oss.sonatype.org/content/repositories/snapshots" - } - } - /* Allow staging references for last pre-release testing. */ - if (project.properties.containsKey("sonatypeUsername")) { - maven { - url "https://oss.sonatype.org/service/local/staging/deploy/maven2" - credentials { - username = project.properties["sonatypeUsername"] - password = project.properties["sonatypePassword"] - } - } - } + mavenLocal() + mavenCentral() } -/* - * Add errorprone checking. - */ dependencies { - errorprone("com.google.errorprone:error_prone_core:2.3.3") - errorproneJavac("com.google.errorprone:javac:9+181-r4173-1") + api "com.github.java-json-tools:jackson-coreutils:2.1-SNAPSHOT" + api "com.github.java-json-tools:msg-simple:1.2" + api "com.google.code.findbugs:jsr305:3.0.2" + + testImplementation "org.testng:testng:7.9.0" + testImplementation "org.assertj:assertj-core:3.25.3" + testImplementation "org.mockito:mockito-core:5.11.0" } -/* - * Necessary! Otherwise TestNG will not be used... - * - */ test { - useTestNG() { - useDefaultListeners = true; - }; -} - -/* - * Necessary to generate the source and javadoc jars - */ -task sourcesJar(type: Jar, dependsOn: classes) { - classifier = "sources"; - from sourceSets.main.allSource; -} - -/* - * Lint all the things! - */ -allprojects { - gradle.projectsEvaluated { - tasks.withType(JavaCompile) { - options.compilerArgs << "-Xlint:all" << "-Xlint:-serial" << "-Werror" - } - tasks.withType(Javadoc) { - options.addStringOption('Xwerror', '-quiet') - } + useTestNG() + testLogging { + events "passed", "skipped", "failed" + exceptionFormat = "full" } } -/* - * Javadoc: we need to tell where the overview.html is, it will not pick it up - * automatically... - */ - -//javadoc { -// options.overview = "src/main/java/overview.html"; -//} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = "javadoc"; - from javadoc.destinationDir; +javadoc { + options.links("https://docs.oracle.com/en/java/javase/17/docs/api/") } -artifacts { - archives jar; - archives sourcesJar; - archives javadocJar; +task testJar(type: Jar) { + archiveClassifier = "tests" + from sourceSets.test.output } -wrapper { - gradleVersion = "5.6.3"; - distributionUrl = "https://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip"; +configurations { + tests } -task pom { - doLast { - pom {}.writeTo("${projectDir}/pom.xml"); - } +artifacts { + tests testJar } -/* - * SIGNING - */ - -project.ext { - scmUrl = sprintf("git@github.com:java-json-tools/%s.git", name); - projectURL = sprintf("https://github.com/java-json-tools/%s", name); - sonatypeStaging = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"; - sonatypeSnapshots = "https://oss.sonatype.org/content/repositories/snapshots/"; -}; - -task checkSigningRequirements { - doLast { - def requiredProperties = [ "sonatypeUsername", "sonatypePassword" ]; - def noDice = false; - requiredProperties.each { - if (project.properties[it] == null) { - noDice = true; - System.err.printf("property \"%s\" is not defined!\n", it); +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + + artifact testJar + + pom { + name = "JSON Patch" + description = "JSON Patch (RFC 6902) and JSON Merge Patch (RFC 7386) implementation in Java" + url = "https://github.com/java-json-tools/json-patch" + + licenses { + license { + name = "Lesser General Public License, version 3 or greater" + url = "http://www.gnu.org/licenses/lgpl.html" + distribution = "repo" + } + license { + name = "Apache Software License, version 2.0" + url = "http://www.apache.org/licenses/LICENSE-2.0" + distribution = "repo" + } + } + + scm { + url = "https://github.com/java-json-tools/json-patch" + connection = "scm:git:git://github.com/java-json-tools/json-patch" + developerConnection = "scm:git:git@github.com:java-json-tools/json-patch" + } + + developers { + developer { + id = "fge" + name = "Francis Galiegue" + email = "fgaliegue@gmail.com" + } + } } } - if (noDice) - throw new IllegalStateException("missing required properties for " + - "upload"); } -} - -uploadArchives { - dependsOn(checkSigningRequirements); + repositories { - mavenDeployer { - beforeDeployment { - MavenDeployment deployment -> signing.signPom(deployment); - } - - repository(url: "${sonatypeStaging}") { - authentication( - userName: project.properties["sonatypeUsername"], - password: project.properties["sonatypePassword"] - ); - } - - snapshotRepository(url: "${sonatypeSnapshots}") { - authentication( - userName: project.properties["sonatypeUsername"], - password: project.properties["sonatypePassword"] - ); - } - } - } -} - -/* - * Configure pom.xml on install, uploadArchives - */ -[ - install.repositories.mavenInstaller, - uploadArchives.repositories.mavenDeployer -]*.pom*.whenConfigured { pom -> - pom.project { - name "${project.name}"; - packaging "jar"; - description "${project.ext.description}"; - url "${projectURL}"; - - scm { - url "${scmUrl}"; - connection "${scmUrl}"; - developerConnection "scm:git:${scmUrl}"; - } - - licenses { - license { - name "Lesser General Public License, version 3 or greater"; - url "http://www.gnu.org/licenses/lgpl.html"; - distribution "repo"; - }; - license { - name "Apache Software License, version 2.0"; - url "http://www.apache.org/licenses/LICENSE-2.0"; - distribution "repo"; - } - } - - developers { - developer { - id "huggsboson"; - name "John Huffaker"; - email "jhuffaker+java-json-tools@gmail.com"; + maven { + def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" + def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/" + url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl + + credentials { + username = project.hasProperty('ossrhUsername') ? ossrhUsername : "N/A" + password = project.hasProperty('ossrhPassword') ? ossrhPassword : "N/A" } } } } signing { - required { forRelease && gradle.taskGraph.hasTask("uploadArchives") }; - sign configurations.archives; + required { gradle.taskGraph.hasTask("publish") } + sign publishing.publications.mavenJava } + diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3a54a333..e69d0402 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew.bat b/gradlew.bat index 24467a14..9618d8d9 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,100 +1,100 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/project.gradle b/project.gradle deleted file mode 100644 index 8d571b35..00000000 --- a/project.gradle +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com) - * - * This software is dual-licensed under: - * - * - the Lesser General Public License (LGPL) version 3.0 or, at your option, any - * later version; - * - the Apache Software License (ASL) version 2.0. - * - * The text of this file and of both licenses is available at the root of this - * project or, if you have the jar distribution, in directory META-INF/, under - * the names LGPL-3.0.txt and ASL-2.0.txt respectively. - * - * Direct link to the sources: - * - * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt - * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt - */ - -/* - * Project-specific settings. Unfortunately we cannot put the name in there! - */ -group = "com.github.java-json-tools"; -version = "1.13"; -sourceCompatibility = JavaVersion.VERSION_1_7; -targetCompatibility = JavaVersion.VERSION_1_7; // defaults to sourceCompatibility -project.ext.description = "JSON Patch (RFC 6902) and JSON Merge Patch (RFC 7386) implementation in Java"; - -/* - * List of dependencies - */ -dependencies { - provided(group: "com.google.code.findbugs", name: "jsr305", version: "3.0.2"); - compile(group: "com.fasterxml.jackson.core", name: "jackson-databind", version: "2.11.0"); - compile(group: "com.github.java-json-tools", name: "msg-simple", version: "1.2"); - - compile(group: "com.github.java-json-tools", name: "jackson-coreutils", version: "2.0"); - testCompile(group: "org.testng", name: "testng", version: "7.1.0") { - exclude(group: "junit", module: "junit"); - exclude(group: "org.beanshell", module: "bsh"); - exclude(group: "org.yaml", module: "snakeyaml"); - }; - testCompile(group: "org.mockito", name: "mockito-core", version: "2.28.2"); - // FIXME: update to 3.x once we're off of Java 7 - testCompile(group: "org.assertj", name: "assertj-core", version: "2.9.1"); - testCompile(group: "com.google.guava", name: "guava", version: "28.2-android"); -} - -javadoc.options { - def currentJavaVersion = org.gradle.api.JavaVersion.current() - // FIXME: https://github.com/gradle/gradle/issues/11182 - if (currentJavaVersion.compareTo(org.gradle.api.JavaVersion.VERSION_1_9) >= 0) { - addStringOption("-release", "7"); - } - links("https://docs.oracle.com/javase/7/docs/api/"); - links("https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/3.0.2/"); - links("https://fasterxml.github.com/jackson-databind/javadoc/2.11/"); - links("https://fasterxml.github.com/jackson-core/javadoc/2.11/"); - links("https://fasterxml.github.com/jackson-annotations/javadoc/2.11/"); - links("https://www.javadoc.io/doc/com.google.guava/guava/28.2-android/"); - links("https://java-json-tools.github.io/msg-simple/"); - links("https://java-json-tools.github.io/jackson-coreutils/"); -} diff --git a/src/main/java/com/github/fge/jsonpatch/AddOperation.java b/src/main/java/com/github/fge/jsonpatch/AddOperation.java index 5e5fb57a..2aa30406 100644 --- a/src/main/java/com/github/fge/jsonpatch/AddOperation.java +++ b/src/main/java/com/github/fge/jsonpatch/AddOperation.java @@ -21,9 +21,9 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; +import tools.jackson.databind.JsonNode; +import tools.jackson.databind.node.ArrayNode; +import tools.jackson.databind.node.ObjectNode; import com.github.fge.jackson.jsonpointer.JsonPointer; import com.github.fge.jackson.jsonpointer.ReferenceToken; import com.github.fge.jackson.jsonpointer.TokenResolver; @@ -93,7 +93,7 @@ public JsonNode apply(final JsonNode node) if (parentNode.isMissingNode()) throw new JsonPatchException(BUNDLE.getMessage( "jsonPatch.noSuchParent")); - if (!parentNode.isContainerNode()) + if (!parentNode.isContainer()) throw new JsonPatchException(BUNDLE.getMessage( "jsonPatch.parentNotContainer")); return parentNode.isArray() diff --git a/src/main/java/com/github/fge/jsonpatch/CopyOperation.java b/src/main/java/com/github/fge/jsonpatch/CopyOperation.java index 9a5a75b9..9c054911 100644 --- a/src/main/java/com/github/fge/jsonpatch/CopyOperation.java +++ b/src/main/java/com/github/fge/jsonpatch/CopyOperation.java @@ -21,7 +21,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.github.fge.jackson.jsonpointer.JsonPointer; /** diff --git a/src/main/java/com/github/fge/jsonpatch/DualPathOperation.java b/src/main/java/com/github/fge/jsonpatch/DualPathOperation.java index 91455bb4..132e268f 100644 --- a/src/main/java/com/github/fge/jsonpatch/DualPathOperation.java +++ b/src/main/java/com/github/fge/jsonpatch/DualPathOperation.java @@ -19,12 +19,12 @@ package com.github.fge.jsonpatch; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.databind.jsontype.TypeSerializer; -import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import tools.jackson.core.JsonGenerator; +import tools.jackson.core.JacksonException; +import tools.jackson.databind.SerializationContext; +import tools.jackson.databind.annotation.JsonSerialize; +import tools.jackson.databind.jsontype.TypeSerializer; +import tools.jackson.databind.ser.std.ToStringSerializer; import com.github.fge.jackson.jsonpointer.JsonPointer; import java.io.IOException; @@ -54,22 +54,22 @@ protected DualPathOperation(final String op, final JsonPointer from, @Override public final void serialize(final JsonGenerator jgen, - final SerializerProvider provider) - throws IOException, JsonProcessingException + final SerializationContext context) + throws JacksonException { jgen.writeStartObject(); - jgen.writeStringField("op", op); - jgen.writeStringField("path", path.toString()); - jgen.writeStringField("from", from.toString()); + jgen.writeStringProperty("op", op); + jgen.writeStringProperty("path", path.toString()); + jgen.writeStringProperty("from", from.toString()); jgen.writeEndObject(); } @Override public final void serializeWithType(final JsonGenerator jgen, - final SerializerProvider provider, final TypeSerializer typeSer) - throws IOException, JsonProcessingException + final SerializationContext context, final TypeSerializer typeSer) + throws JacksonException { - serialize(jgen, provider); + serialize(jgen, context); } public final JsonPointer getFrom() { diff --git a/src/main/java/com/github/fge/jsonpatch/JsonPatch.java b/src/main/java/com/github/fge/jsonpatch/JsonPatch.java index b41ed6bb..dd38a4c4 100644 --- a/src/main/java/com/github/fge/jsonpatch/JsonPatch.java +++ b/src/main/java/com/github/fge/jsonpatch/JsonPatch.java @@ -20,11 +20,11 @@ package com.github.fge.jsonpatch; import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.JsonSerializable; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.jsontype.TypeSerializer; +import tools.jackson.core.JsonGenerator; +import tools.jackson.databind.JsonNode; +import tools.jackson.databind.JacksonSerializable; +import tools.jackson.databind.SerializationContext; +import tools.jackson.databind.jsontype.TypeSerializer; import com.github.fge.jackson.JacksonUtils; import com.github.fge.msgsimple.bundle.MessageBundle; import com.github.fge.msgsimple.load.MessageBundles; @@ -91,7 +91,7 @@ * constructor for this class ({@link JsonPatch#fromJson(JsonNode)} is used.
*/ public final class JsonPatch - implements JsonSerializable, Patch + implements JacksonSerializable, Patch { private static final MessageBundle BUNDLE = MessageBundles.getBundle(JsonPatchMessages.class); @@ -163,20 +163,18 @@ public String toString() @Override public void serialize(final JsonGenerator jgen, - final SerializerProvider provider) - throws IOException + final SerializationContext context) { jgen.writeStartArray(); for (final JsonPatchOperation op: operations) - op.serialize(jgen, provider); + op.serialize(jgen, context); jgen.writeEndArray(); } @Override public void serializeWithType(final JsonGenerator jgen, - final SerializerProvider provider, final TypeSerializer typeSer) - throws IOException + final SerializationContext context, final TypeSerializer typeSer) { - serialize(jgen, provider); + serialize(jgen, context); } } diff --git a/src/main/java/com/github/fge/jsonpatch/JsonPatchOperation.java b/src/main/java/com/github/fge/jsonpatch/JsonPatchOperation.java index 06a6a62d..156190f5 100644 --- a/src/main/java/com/github/fge/jsonpatch/JsonPatchOperation.java +++ b/src/main/java/com/github/fge/jsonpatch/JsonPatchOperation.java @@ -22,8 +22,8 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.JsonSerializable; +import tools.jackson.databind.JsonNode; +import tools.jackson.databind.JacksonSerializable; import com.github.fge.jackson.jsonpointer.JsonPointer; import com.github.fge.msgsimple.bundle.MessageBundle; import com.github.fge.msgsimple.load.MessageBundles; @@ -57,7 +57,7 @@ */ @JsonIgnoreProperties(ignoreUnknown = true) public abstract class JsonPatchOperation - implements JsonSerializable + implements JacksonSerializable { protected static final MessageBundle BUNDLE = MessageBundles.getBundle(JsonPatchMessages.class); diff --git a/src/main/java/com/github/fge/jsonpatch/MoveOperation.java b/src/main/java/com/github/fge/jsonpatch/MoveOperation.java index 405b737c..fc3fd0ac 100644 --- a/src/main/java/com/github/fge/jsonpatch/MoveOperation.java +++ b/src/main/java/com/github/fge/jsonpatch/MoveOperation.java @@ -21,7 +21,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.github.fge.jackson.jsonpointer.JsonPointer; /** diff --git a/src/main/java/com/github/fge/jsonpatch/Patch.java b/src/main/java/com/github/fge/jsonpatch/Patch.java index adce2042..0a37990b 100644 --- a/src/main/java/com/github/fge/jsonpatch/Patch.java +++ b/src/main/java/com/github/fge/jsonpatch/Patch.java @@ -1,6 +1,6 @@ package com.github.fge.jsonpatch; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; public interface Patch { diff --git a/src/main/java/com/github/fge/jsonpatch/PathValueOperation.java b/src/main/java/com/github/fge/jsonpatch/PathValueOperation.java index 523ea662..d344e523 100644 --- a/src/main/java/com/github/fge/jsonpatch/PathValueOperation.java +++ b/src/main/java/com/github/fge/jsonpatch/PathValueOperation.java @@ -19,12 +19,12 @@ package com.github.fge.jsonpatch; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.databind.jsontype.TypeSerializer; +import tools.jackson.core.JsonGenerator; +import tools.jackson.core.JacksonException; +import tools.jackson.databind.JsonNode; +import tools.jackson.databind.SerializationContext; +import tools.jackson.databind.annotation.JsonSerialize; +import tools.jackson.databind.jsontype.TypeSerializer; import com.github.fge.jackson.jsonpointer.JsonPointer; import java.io.IOException; @@ -54,23 +54,23 @@ protected PathValueOperation(final String op, final JsonPointer path, @Override public final void serialize(final JsonGenerator jgen, - final SerializerProvider provider) - throws IOException, JsonProcessingException + final SerializationContext context) + throws JacksonException { jgen.writeStartObject(); - jgen.writeStringField("op", op); - jgen.writeStringField("path", path.toString()); - jgen.writeFieldName("value"); + jgen.writeStringProperty("op", op); + jgen.writeStringProperty("path", path.toString()); + jgen.writeName("value"); jgen.writeTree(value); jgen.writeEndObject(); } @Override public final void serializeWithType(final JsonGenerator jgen, - final SerializerProvider provider, final TypeSerializer typeSer) - throws IOException, JsonProcessingException + final SerializationContext context, final TypeSerializer typeSer) + throws JacksonException { - serialize(jgen, provider); + serialize(jgen, context); } public final JsonNode getValue() { diff --git a/src/main/java/com/github/fge/jsonpatch/RemoveOperation.java b/src/main/java/com/github/fge/jsonpatch/RemoveOperation.java index 4c528baa..19a8f9c5 100644 --- a/src/main/java/com/github/fge/jsonpatch/RemoveOperation.java +++ b/src/main/java/com/github/fge/jsonpatch/RemoveOperation.java @@ -21,14 +21,14 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.jsontype.TypeSerializer; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.MissingNode; -import com.fasterxml.jackson.databind.node.ObjectNode; +import tools.jackson.core.JsonGenerator; +import tools.jackson.core.JacksonException; +import tools.jackson.databind.JsonNode; +import tools.jackson.databind.SerializationContext; +import tools.jackson.databind.jsontype.TypeSerializer; +import tools.jackson.databind.node.ArrayNode; +import tools.jackson.databind.node.MissingNode; +import tools.jackson.databind.node.ObjectNode; import com.github.fge.jackson.jsonpointer.JsonPointer; import java.io.IOException; @@ -69,21 +69,21 @@ public JsonNode apply(final JsonNode node) @Override public void serialize(final JsonGenerator jgen, - final SerializerProvider provider) - throws IOException, JsonProcessingException + final SerializationContext context) + throws JacksonException { jgen.writeStartObject(); - jgen.writeStringField("op", "remove"); - jgen.writeStringField("path", path.toString()); + jgen.writeStringProperty("op", "remove"); + jgen.writeStringProperty("path", path.toString()); jgen.writeEndObject(); } @Override public void serializeWithType(final JsonGenerator jgen, - final SerializerProvider provider, final TypeSerializer typeSer) - throws IOException, JsonProcessingException + final SerializationContext context, final TypeSerializer typeSer) + throws JacksonException { - serialize(jgen, provider); + serialize(jgen, context); } @Override diff --git a/src/main/java/com/github/fge/jsonpatch/ReplaceOperation.java b/src/main/java/com/github/fge/jsonpatch/ReplaceOperation.java index d4454bdb..0343256b 100644 --- a/src/main/java/com/github/fge/jsonpatch/ReplaceOperation.java +++ b/src/main/java/com/github/fge/jsonpatch/ReplaceOperation.java @@ -21,9 +21,9 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; +import tools.jackson.databind.JsonNode; +import tools.jackson.databind.node.ArrayNode; +import tools.jackson.databind.node.ObjectNode; import com.github.fge.jackson.jsonpointer.JsonPointer; /** diff --git a/src/main/java/com/github/fge/jsonpatch/TestOperation.java b/src/main/java/com/github/fge/jsonpatch/TestOperation.java index 90f03401..b2c793f3 100644 --- a/src/main/java/com/github/fge/jsonpatch/TestOperation.java +++ b/src/main/java/com/github/fge/jsonpatch/TestOperation.java @@ -21,7 +21,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.github.fge.jackson.JsonNumEquals; import com.github.fge.jackson.jsonpointer.JsonPointer; diff --git a/src/main/java/com/github/fge/jsonpatch/diff/DiffOperation.java b/src/main/java/com/github/fge/jsonpatch/diff/DiffOperation.java index fac687fd..0d1abe8d 100644 --- a/src/main/java/com/github/fge/jsonpatch/diff/DiffOperation.java +++ b/src/main/java/com/github/fge/jsonpatch/diff/DiffOperation.java @@ -19,7 +19,7 @@ package com.github.fge.jsonpatch.diff; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.github.fge.jackson.jsonpointer.JsonPointer; import com.github.fge.jsonpatch.AddOperation; import com.github.fge.jsonpatch.CopyOperation; diff --git a/src/main/java/com/github/fge/jsonpatch/diff/DiffProcessor.java b/src/main/java/com/github/fge/jsonpatch/diff/DiffProcessor.java index 299d29a1..e2dec77c 100644 --- a/src/main/java/com/github/fge/jsonpatch/diff/DiffProcessor.java +++ b/src/main/java/com/github/fge/jsonpatch/diff/DiffProcessor.java @@ -19,7 +19,7 @@ package com.github.fge.jsonpatch.diff; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.github.fge.jackson.JsonNumEquals; import com.github.fge.jackson.jsonpointer.JsonPointer; import com.github.fge.jsonpatch.JsonPatch; diff --git a/src/main/java/com/github/fge/jsonpatch/diff/JsonDiff.java b/src/main/java/com/github/fge/jsonpatch/diff/JsonDiff.java index 302a79c2..40d7ede3 100644 --- a/src/main/java/com/github/fge/jsonpatch/diff/JsonDiff.java +++ b/src/main/java/com/github/fge/jsonpatch/diff/JsonDiff.java @@ -19,10 +19,10 @@ package com.github.fge.jsonpatch.diff; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; +import tools.jackson.databind.JsonNode; +import tools.jackson.databind.ObjectMapper; +import tools.jackson.databind.node.ArrayNode; +import tools.jackson.databind.node.ObjectNode; import com.github.fge.jackson.JacksonUtils; import com.github.fge.jackson.JsonNumEquals; import com.github.fge.jackson.NodeType; @@ -108,7 +108,7 @@ public static JsonNode asJson(final JsonNode source, final JsonNode target) try { s = MAPPER.writeValueAsString(asJsonPatch(source, target)); return MAPPER.readTree(s); - } catch (IOException e) { + } catch (Exception e) { throw new RuntimeException("cannot generate JSON diff", e); } } @@ -136,7 +136,7 @@ private static void generateDiffs(final DiffProcessor processor, * * If this is not a container, generate a replace operation. */ - if (!source.isContainerNode()) { + if (!source.isContainer()) { processor.valueReplaced(pointer, source, target); return; } @@ -157,10 +157,9 @@ private static void generateObjectDiffs(final DiffProcessor processor, final JsonPointer pointer, final ObjectNode source, final ObjectNode target) { - final SetThe main class is {@link com.github.fge.jsonpatch.JsonPatch}.
* *Note that at this moment, the only way to build a patch is from a JSON - * representation (as a {@link com.fasterxml.jackson.databind.JsonNode}).
+ * representation (as a {@link tools.jackson.databind.JsonNode}). * */ package com.github.fge.jsonpatch; diff --git a/src/test/java/com/github/fge/jsonpatch/JsonPatchOperationTest.java b/src/test/java/com/github/fge/jsonpatch/JsonPatchOperationTest.java index 5f04d811..69ed25eb 100644 --- a/src/test/java/com/github/fge/jsonpatch/JsonPatchOperationTest.java +++ b/src/test/java/com/github/fge/jsonpatch/JsonPatchOperationTest.java @@ -19,18 +19,18 @@ package com.github.fge.jsonpatch; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectReader; +import tools.jackson.databind.JsonNode; +import tools.jackson.databind.ObjectReader; import com.github.fge.jackson.JacksonUtils; import com.github.fge.jackson.JsonLoader; import com.github.fge.jackson.JsonNumEquals; import com.github.fge.msgsimple.bundle.MessageBundle; import com.github.fge.msgsimple.load.MessageBundles; -import com.google.common.collect.Lists; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import java.io.IOException; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -63,7 +63,7 @@ protected JsonPatchOperationTest(final String prefix) public final Iterator