From 81e90fdc1ca5b7a6d1545ae0a2b1ac01ac70b92e Mon Sep 17 00:00:00 2001 From: Carter Kozak Date: Wed, 10 Apr 2024 14:26:36 -0400 Subject: [PATCH 1/3] Remove Dependency on Jackson Afterburner Afterburner is not used on supported JDKs, there's no reason to include the dependency. --- .../build.gradle | 1 - .../ObjectMapperOptimizations.java | 29 ++++--------------- versions.lock | 5 ++-- 3 files changed, 7 insertions(+), 28 deletions(-) diff --git a/conjure-java-jackson-optimizations/build.gradle b/conjure-java-jackson-optimizations/build.gradle index c1641e2e9..a90f820eb 100644 --- a/conjure-java-jackson-optimizations/build.gradle +++ b/conjure-java-jackson-optimizations/build.gradle @@ -3,5 +3,4 @@ apply plugin: 'com.palantir.revapi' dependencies { api "com.fasterxml.jackson.core:jackson-databind" - implementation "com.fasterxml.jackson.module:jackson-module-afterburner" } diff --git a/conjure-java-jackson-optimizations/src/main/java/com/palantir/conjure/java/jackson/optimizations/ObjectMapperOptimizations.java b/conjure-java-jackson-optimizations/src/main/java/com/palantir/conjure/java/jackson/optimizations/ObjectMapperOptimizations.java index 21556e67e..e68996a8c 100644 --- a/conjure-java-jackson-optimizations/src/main/java/com/palantir/conjure/java/jackson/optimizations/ObjectMapperOptimizations.java +++ b/conjure-java-jackson-optimizations/src/main/java/com/palantir/conjure/java/jackson/optimizations/ObjectMapperOptimizations.java @@ -16,7 +16,6 @@ package com.palantir.conjure.java.jackson.optimizations; -import com.fasterxml.jackson.module.afterburner.AfterburnerModule; import java.util.List; /** @@ -26,31 +25,13 @@ */ public final class ObjectMapperOptimizations { - private static final boolean NO_OPTIMIZATIONS = - // These optimizations are not used within graalvm because they leverage dynamic class creation The - // nativeimage check should not be refactored into a utility method which may reduce our ability to - // tree-shake. - System.getProperty("org.graalvm.nativeimage.imagecode") != null - // This may be globally configured with a system property - || readProperty( - "com.palantir.conjure.java.jackson.optimizations.disabled", shouldDisableByDefault()); - - @SuppressWarnings("AfterburnerJavaIncompatibility") public static List createModules() { - return NO_OPTIMIZATIONS ? List.of() : List.of(new AfterburnerModule()); - } - - private ObjectMapperOptimizations() {} - - /** - * We disable afterburner optimizations by default on java 16+ where internal access is - * restricted by https://openjdk.java.net/jeps/396 and https://openjdk.java.net/jeps/403. - */ - private static boolean shouldDisableByDefault() { - return Runtime.version().feature() >= 16; + // At one point this conditionally returned List.of(new AfterburnerModule), however afterburner is not + // supported on any supported LTS Java release anymore, and the Blackbird alternative incurs a memory + // leak (https://github.com/FasterXML/jackson-modules-base/issues/147). + return List.of(); } - private static boolean readProperty(String property, boolean defaultValue) { - return Boolean.parseBoolean(System.getProperty(property, Boolean.toString(defaultValue))); + private ObjectMapperOptimizations() { } } diff --git a/versions.lock b/versions.lock index eb86391d9..92fe251bc 100644 --- a/versions.lock +++ b/versions.lock @@ -1,8 +1,8 @@ # Run ./gradlew writeVersionsLock to regenerate this file com.fasterxml:classmate:1.5.1 (1 constraints: 9a122a13) com.fasterxml.jackson.core:jackson-annotations:2.15.3 (11 constraints: a5cb8531) -com.fasterxml.jackson.core:jackson-core:2.15.3 (15 constraints: 6f3b8e5f) -com.fasterxml.jackson.core:jackson-databind:2.15.3 (19 constraints: 657bcd19) +com.fasterxml.jackson.core:jackson-core:2.15.3 (14 constraints: ec23b668) +com.fasterxml.jackson.core:jackson-databind:2.15.3 (18 constraints: e263a4e3) com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:2.15.3 (2 constraints: 3220a606) com.fasterxml.jackson.dataformat:jackson-dataformat-smile:2.15.3 (1 constraints: 3c05423b) com.fasterxml.jackson.datatype:jackson-datatype-guava:2.15.3 (1 constraints: 3c05423b) @@ -11,7 +11,6 @@ com.fasterxml.jackson.datatype:jackson-datatype-joda:2.15.3 (1 constraints: 3c05 com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.15.3 (1 constraints: 3c05423b) com.fasterxml.jackson.jakarta.rs:jackson-jakarta-rs-base:2.15.3 (1 constraints: f71afd42) com.fasterxml.jackson.jakarta.rs:jackson-jakarta-rs-cbor-provider:2.15.3 (1 constraints: 3c05423b) -com.fasterxml.jackson.module:jackson-module-afterburner:2.15.3 (1 constraints: 3c05423b) com.fasterxml.jackson.module:jackson-module-jakarta-xmlbind-annotations:2.15.3 (2 constraints: e4300fb4) com.fasterxml.jackson.module:jackson-module-scala_2.12:2.15.3 (1 constraints: 3c05423b) com.github.ben-manes.caffeine:caffeine:3.1.8 (3 constraints: f223e4a4) From 5e70b5d7952aadbd594d6fbf62c6eadf801c2f6e Mon Sep 17 00:00:00 2001 From: svc-changelog Date: Wed, 10 Apr 2024 18:29:54 +0000 Subject: [PATCH 2/3] Add generated changelog entries --- changelog/@unreleased/pr-2879.v2.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelog/@unreleased/pr-2879.v2.yml diff --git a/changelog/@unreleased/pr-2879.v2.yml b/changelog/@unreleased/pr-2879.v2.yml new file mode 100644 index 000000000..2487fa6b4 --- /dev/null +++ b/changelog/@unreleased/pr-2879.v2.yml @@ -0,0 +1,5 @@ +type: improvement +improvement: + description: Remove Dependency on Jackson Afterburner + links: + - https://github.com/palantir/conjure-java-runtime/pull/2879 From 45dc055c9804913b5001ffc7f88954586300627d Mon Sep 17 00:00:00 2001 From: Carter Kozak Date: Wed, 10 Apr 2024 15:09:26 -0400 Subject: [PATCH 3/3] fmt --- .../java/jackson/optimizations/ObjectMapperOptimizations.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/conjure-java-jackson-optimizations/src/main/java/com/palantir/conjure/java/jackson/optimizations/ObjectMapperOptimizations.java b/conjure-java-jackson-optimizations/src/main/java/com/palantir/conjure/java/jackson/optimizations/ObjectMapperOptimizations.java index e68996a8c..1208614fc 100644 --- a/conjure-java-jackson-optimizations/src/main/java/com/palantir/conjure/java/jackson/optimizations/ObjectMapperOptimizations.java +++ b/conjure-java-jackson-optimizations/src/main/java/com/palantir/conjure/java/jackson/optimizations/ObjectMapperOptimizations.java @@ -32,6 +32,5 @@ public static List createModule return List.of(); } - private ObjectMapperOptimizations() { - } + private ObjectMapperOptimizations() {} }