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

Ban AfterburnerModule to reduce JDK-17 risk #2032

Merged
merged 3 commits into from
Jan 12, 2022
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
1 change: 1 addition & 0 deletions baseline-error-prone/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-migrationsupport'
testRuntimeOnly 'one.util:streamex'
testRuntimeOnly 'com.fasterxml.jackson.module:jackson-module-afterburner'

annotationProcessor 'com.google.auto.service:auto-service'
annotationProcessor 'org.immutables:value'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* (c) Copyright 2020 Palantir Technologies Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.palantir.baseline.errorprone;

import com.google.auto.service.AutoService;
import com.google.errorprone.BugPattern;
import com.google.errorprone.VisitorState;
import com.google.errorprone.bugpatterns.BugChecker;
import com.google.errorprone.matchers.Description;
import com.google.errorprone.matchers.Matcher;
import com.google.errorprone.matchers.method.MethodMatchers;
import com.sun.source.tree.ExpressionTree;
import com.sun.source.tree.NewClassTree;

@AutoService(BugChecker.class)
@BugPattern(
name = "AfterburnerJavaIncompatibility",
link = "https://github.com/palantir/gradle-baseline#baseline-error-prone-checks",
linkType = BugPattern.LinkType.CUSTOM,
severity = BugPattern.SeverityLevel.ERROR,
summary = "The AfterburnerModule is not compatible with jdk16+ and will cause failures at runtime. "
+ "Either remove AfterburnerModule, or replace it with 'conjure-java-jackson-optimizations' "
+ "ObjectMapperOptimizations.createModules() to take the runtime into account.")
public final class AfterburnerJavaIncompatibility extends BugChecker implements BugChecker.NewClassTreeMatcher {

private static final Matcher<ExpressionTree> MATCHER =
MethodMatchers.constructor().forClass("com.fasterxml.jackson.module.afterburner.AfterburnerModule");

@Override
public Description matchNewClass(NewClassTree tree, VisitorState state) {
return MATCHER.matches(tree, state) ? describeMatch(tree) : Description.NO_MATCH;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* (c) Copyright 2022 Palantir Technologies Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.palantir.baseline.errorprone;

import com.google.errorprone.CompilationTestHelper;
import org.junit.jupiter.api.Test;

class AfterburnerJavaIncompatibilityTest {

@Test
void afterburnerNotAllowed() {
helper().addSourceLines(
"Test.java",
"import com.fasterxml.jackson.module.afterburner.AfterburnerModule;",
"public class Test {",
" // BUG: Diagnostic contains: AfterburnerModule",
" AfterburnerModule module = new AfterburnerModule();",
"}")
.doTest();
}

private CompilationTestHelper helper() {
return CompilationTestHelper.newInstance(AfterburnerJavaIncompatibility.class, getClass());
}
}
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-2032.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: Ban AfterburnerModule to reduce JDK-17 risk
links:
- https://github.com/palantir/gradle-baseline/pull/2032
5 changes: 3 additions & 2 deletions versions.lock
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ org.slf4j:slf4j-api:1.7.32 (6 constraints: 1a527c1a)
cglib:cglib-nodep:3.3.0 (2 constraints: 7a1acf3c)
com.fasterxml.jackson:jackson-bom:2.12.5 (3 constraints: 8537f0d4)
com.fasterxml.jackson.core:jackson-annotations:2.12.5 (5 constraints: 0f441ffd)
com.fasterxml.jackson.core:jackson-core:2.12.5 (2 constraints: 43215694)
com.fasterxml.jackson.core:jackson-databind:2.12.5 (4 constraints: aa3cb9a4)
com.fasterxml.jackson.core:jackson-core:2.12.5 (3 constraints: c5381d44)
com.fasterxml.jackson.core:jackson-databind:2.12.5 (5 constraints: 2c542cee)
com.fasterxml.jackson.module:jackson-module-afterburner:2.12.5 (2 constraints: f013f981)
com.github.stefanbirkner:system-rules:1.19.0 (1 constraints: 3d05443b)
com.netflix.nebula:nebula-test:10.1.0 (1 constraints: 34052a3b)
com.palantir.conjure.java:conjure-lib:6.9.0 (1 constraints: 11052436)
Expand Down