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

Remove Dependency on Jackson Afterburner #2879

Merged
merged 3 commits into from
Apr 10, 2024
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
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-2879.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: Remove Dependency on Jackson Afterburner
links:
- https://github.com/palantir/conjure-java-runtime/pull/2879
1 change: 0 additions & 1 deletion conjure-java-jackson-optimizations/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.palantir.conjure.java.jackson.optimizations;

import com.fasterxml.jackson.module.afterburner.AfterburnerModule;
import java.util.List;

/**
Expand All @@ -26,31 +25,12 @@
*/
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<? extends com.fasterxml.jackson.databind.Module> createModules() {
return NO_OPTIMIZATIONS ? List.of() : List.<com.fasterxml.jackson.databind.Module>of(new AfterburnerModule());
// 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 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;
}

private static boolean readProperty(String property, boolean defaultValue) {
return Boolean.parseBoolean(System.getProperty(property, Boolean.toString(defaultValue)));
}
}
5 changes: 2 additions & 3 deletions versions.lock
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand Down