Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
cb81424
build: Enforce a JDK 21 to run Gradle
bric3 Sep 12, 2025
ca82eea
fix: SpotBugs needs 6.4.2 to run after JDK11, relax forbiddenApis on …
bric3 Sep 18, 2025
88ef442
fix: Try fixing spotted bugs
bric3 Sep 19, 2025
9510177
Merge branch 'bdu/test-decoupling-on-jdk21' into bdu/spotbugs-bump-ne…
AlexeyKuznetsov-DD Oct 22, 2025
095d027
Merged with master.
AlexeyKuznetsov-DD Oct 23, 2025
aae1e80
Made latest SpotBugs passing.
AlexeyKuznetsov-DD Oct 23, 2025
e4a8703
Cleanup classpath to resolve JUnit5 versions conflict.
AlexeyKuznetsov-DD Oct 24, 2025
261aea6
Cleanup classpath to resolve JUnit5 versions conflict.
AlexeyKuznetsov-DD Oct 24, 2025
b5f246e
Exclude logback.
AlexeyKuznetsov-DD Oct 24, 2025
03ac8e4
Merge branch 'master' into bdu/spotbugs-bump-need-jdk11-min
AlexeyKuznetsov-DD Oct 27, 2025
308bca2
Fixed failed log4j test.
AlexeyKuznetsov-DD Oct 27, 2025
b4b8e64
Merge branch 'master' into bdu/spotbugs-bump-need-jdk11-min
AlexeyKuznetsov-DD Oct 27, 2025
6eceae4
Merge branch 'master' into bdu/spotbugs-bump-need-jdk11-min
AlexeyKuznetsov-DD Oct 29, 2025
51c0d79
Merge branch 'master' into bdu/spotbugs-bump-need-jdk11-min
AlexeyKuznetsov-DD Nov 3, 2025
75bdff2
Removed not relevant props
AlexeyKuznetsov-DD Nov 3, 2025
99153b9
Merge branch 'master' into bdu/spotbugs-bump-need-jdk11-min
AlexeyKuznetsov-DD Nov 10, 2025
1ddcaf3
Merge branch 'master' into bdu/spotbugs-bump-need-jdk11-min
AlexeyKuznetsov-DD Nov 11, 2025
59e939e
Merge branch 'master' into bdu/spotbugs-bump-need-jdk11-min
AlexeyKuznetsov-DD Nov 12, 2025
095b160
Merge branch 'master' into bdu/spotbugs-bump-need-jdk11-min
AlexeyKuznetsov-DD Nov 13, 2025
cb6d41d
Merge branch 'master' into bdu/spotbugs-bump-need-jdk11-min
AlexeyKuznetsov-DD Nov 13, 2025
f8554c1
Bump to 6.4.5
AlexeyKuznetsov-DD Nov 13, 2025
516bec0
Merge branch 'master' into bdu/spotbugs-bump-need-jdk11-min
AlexeyKuznetsov-DD Nov 17, 2025
047068e
Merge branch 'master' into bdu/spotbugs-bump-need-jdk11-min
AlexeyKuznetsov-DD Nov 20, 2025
0e4993f
Merge branch 'master' into bdu/spotbugs-bump-need-jdk11-min
AlexeyKuznetsov-DD Nov 21, 2025
1eb01c1
Merge branch 'master' into bdu/spotbugs-bump-need-jdk11-min
AlexeyKuznetsov-DD Nov 21, 2025
dd1b15c
Merge branch 'master' into bdu/spotbugs-bump-need-jdk11-min
AlexeyKuznetsov-DD Nov 24, 2025
6b2478d
Replaced code changes with `@SuppressFBWarnings` annotations.
AlexeyKuznetsov-DD Nov 24, 2025
275691f
chore: Apply PR suggestions from code review
bric3 Nov 28, 2025
71a8b84
Merge branch 'master' into alexeyk/spotbugs-base
AlexeyKuznetsov-DD Dec 1, 2025
454a39d
Spotless.
AlexeyKuznetsov-DD Dec 1, 2025
5412aee
Latest Spotbugs
AlexeyKuznetsov-DD Dec 1, 2025
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 build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ plugins {
id("dd-trace-java.ci-jobs")

id("com.diffplug.spotless") version "6.13.0"
id("com.github.spotbugs") version "5.0.14"
id("de.thetaphi.forbiddenapis") version "3.8"
id("com.github.spotbugs") version "6.4.7"
id("de.thetaphi.forbiddenapis") version "3.10"
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
id("com.gradleup.shadow") version "8.3.6" apply false
id("me.champeau.jmh") version "0.7.3" apply false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies {
testImplementation(libs.groovy)
testImplementation(libs.bundles.spock)
testImplementation("javax.servlet", "javax.servlet-api", "3.0.1")
testImplementation("com.github.spotbugs", "spotbugs-annotations", "4.2.0")
testImplementation(libs.spotbugs.annotations)
}

sourceSets {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import datadog.remoteconfig.DefaultConfigurationPoller;
import datadog.trace.api.Config;
import datadog.trace.util.AgentTaskScheduler;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.security.Security;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -31,6 +32,7 @@ public class SharedCommunicationObjects {
* HTTP client for making requests to Datadog agent. Depending on configuration, this client may
* use regular HTTP, UDS or named pipe.
*/
@SuppressFBWarnings("PA_PUBLIC_PRIMITIVE_ATTRIBUTE")
public OkHttpClient agentHttpClient;

/**
Expand All @@ -39,10 +41,18 @@ public class SharedCommunicationObjects {
*/
private volatile OkHttpClient intakeHttpClient;

@SuppressFBWarnings("PA_PUBLIC_PRIMITIVE_ATTRIBUTE")
public long httpClientTimeout;

@SuppressFBWarnings("PA_PUBLIC_PRIMITIVE_ATTRIBUTE")
public boolean forceClearTextHttpForIntakeClient;

@SuppressFBWarnings("PA_PUBLIC_PRIMITIVE_ATTRIBUTE")
public HttpUrl agentUrl;

@SuppressFBWarnings("PA_PUBLIC_PRIMITIVE_ATTRIBUTE")
public Monitoring monitoring;

private volatile DDAgentFeaturesDiscovery featuresDiscovery;
private ConfigurationPoller configurationPoller;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
public final class DDAgentStatsDClientManager implements StatsDClientManager {
private static final DDAgentStatsDClientManager INSTANCE = new DDAgentStatsDClientManager();

private DDAgentStatsDClientManager() {}

private static final boolean USE_LOGGING_CLIENT =
LOGGING_WRITER_TYPE.equals(Config.get().getWriterType());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import datadog.trace.util.AgentTaskScheduler;
import datadog.trace.util.AgentThreadFactory.AgentThread;
import datadog.trace.util.throwable.FatalAgentMisconfigurationError;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.lang.instrument.Instrumentation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -202,6 +203,7 @@ private static void safelySetContextClassLoader(ClassLoader classLoader) {
* <p>The Agent is considered to start successfully if Instrumentation can be activated. All other
* pieces are considered optional.
*/
@SuppressFBWarnings("AT_STALE_THREAD_WRITE_OF_PRIMITIVE")
public static void start(
final Object bootstrapInitTelemetry,
final Instrumentation inst,
Expand Down Expand Up @@ -460,6 +462,7 @@ private static void injectAgentArgsConfig(String agentArgs) {
}
}

@SuppressFBWarnings("AT_STALE_THREAD_WRITE_OF_PRIMITIVE")
private static void configureCiVisibility(URL agentJarURL) {
// Retro-compatibility for the old way to configure CI Visibility
if ("true".equals(ddGetProperty("dd.integration.junit.enabled"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static PatchLogger getAnonymousLogger(final String resourceBundleName) {
return SAFE_LOGGER;
}

protected PatchLogger(final String name, final String resourceBundleName) {
private PatchLogger(final String name, final String resourceBundleName) {
// super(name, resourceBundleName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import datadog.trace.api.Config;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.ArrayDeque;
import java.util.Collections;
import java.util.Comparator;
Expand Down Expand Up @@ -65,7 +64,6 @@ public int compare(Map.Entry<Thread, TimeInQueue> o1, Map.Entry<Thread, TimeInQu
private volatile int timeInQueueSpanCount = 0;

// this field is protected by synchronization of capturedSpans, but SpotBugs miss that
@SuppressFBWarnings("IS2_INCONSISTENT_SYNC")
private boolean capturingFlipped = false;

public SessionState(int ackMode, boolean timeInQueueEnabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
import datadog.trace.api.civisibility.execution.TestExecutionPolicy;
import datadog.trace.api.civisibility.execution.TestStatus;
import datadog.trace.api.civisibility.telemetry.tag.RetryReason;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.concurrent.atomic.AtomicInteger;

/** Retries a test case if it failed, up to a maximum number of times. */
@SuppressFBWarnings(
value = {"AT_NONATOMIC_OPERATIONS_ON_SHARED_VARIABLE", "AT_STALE_THREAD_WRITE_OF_PRIMITIVE"},
justification =
"TestExecutionPolicy instances are confined to a single thread and are not meant to be thread-safe")
public class RetryUntilSuccessful implements TestExecutionPolicy {

private final int maxExecutions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import datadog.trace.agent.test.utils.OkHttpUtils
import datadog.trace.api.gateway.IGSpanInfo
import datadog.trace.api.gateway.RequestContext
import datadog.trace.api.gateway.RequestContextSlot
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings
import okhttp3.OkHttpClient

import java.util.concurrent.LinkedBlockingQueue
import java.util.concurrent.TimeUnit

@SuppressFBWarnings("HSM_HIDING_METHOD")
class IastRequestTestRunner extends IastAgentTestRunner implements IastRequestContextPreparationTrait {

private static final LinkedBlockingQueue<TaintedObjectCollection> TAINTED_OBJECTS = new LinkedBlockingQueue<>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import datadog.trace.api.iast.telemetry.Verbosity;
import datadog.trace.util.AgentTaskScheduler;
import datadog.trace.util.stacktrace.StackWalkerFactory;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.lang.instrument.Instrumentation;
import java.lang.reflect.Constructor;
import java.lang.reflect.UndeclaredThrowableException;
Expand All @@ -70,7 +71,11 @@
public class IastSystem {

private static final Logger LOGGER = LoggerFactory.getLogger(IastSystem.class);

@SuppressFBWarnings("PA_PUBLIC_PRIMITIVE_ATTRIBUTE")
public static boolean DEBUG = false;

@SuppressFBWarnings("PA_PUBLIC_PRIMITIVE_ATTRIBUTE")
public static Verbosity VERBOSITY = Verbosity.OFF;

public static void start(final SubscriptionService ss) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ public void onStringConcatFactory(
}

@Override
@SuppressFBWarnings("ES_COMPARING_PARAMETER_STRING_WITH_EQ")
public void onStringSubSequence(
@Nonnull CharSequence self, int beginIndex, int endIndex, @Nullable CharSequence result) {
if (self == result || !canBeTainted(result)) {
Expand Down Expand Up @@ -746,7 +745,6 @@ public void onStringReplace(

/** This method is used to make an {@code CallSite.Around} of the {@code String.replace} method */
@Override
@SuppressFBWarnings("ES_COMPARING_PARAMETER_STRING_WITH_EQ")
public String onStringReplace(
@Nonnull String self, CharSequence oldCharSeq, CharSequence newCharSeq) {
final IastContext ctx = IastContext.Provider.get();
Expand Down Expand Up @@ -829,7 +827,6 @@ public String onStringReplace(
}

@Override
@SuppressFBWarnings("ES_COMPARING_PARAMETER_STRING_WITH_EQ")
public void onStringValueOf(Object param, @Nonnull String result) {
if (param == null || !canBeTainted(result)) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import datadog.trace.api.iast.telemetry.IastMetricCollector;
import datadog.trace.api.iast.telemetry.Verbosity;
import datadog.trace.util.AgentTaskScheduler;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
Expand Down Expand Up @@ -102,6 +103,10 @@ class TaintedMapImpl implements TaintedMap, Runnable {
/**
* Flag for the current alive tainted objects (red/black style marking for max age calculation).
*/
@SuppressFBWarnings(
value = "AT_STALE_THREAD_WRITE_OF_PRIMITIVE",
justification =
"The design explicitly tolerates losses in high-concurrency scenarios. The delayed visibility of the generation flag can cause some entries to be purged a bit earlier or later than ideal, but this is still within the acceptable boundaries of the design.")
protected boolean generation;

/** Whether to collect the {@link IastMetric#TAINTED_FLAT_MODE} metric or not */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static boolean checkEnvironment(String temp, StringBuilder sb) {
boolean result = false;
result |= checkJFR(sb);
result |= checkDdprof(sb);
if (!result) {;
if (!result) {
appendLine("Profiler is not supported on this JVM.", sb);
return false;
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.datadog.profiling.utils;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;

public interface Timestamper {
Expand Down Expand Up @@ -33,6 +34,7 @@ static boolean override(Timestamper timestamper) {
Registration.INSTANCE, Timestamper.DEFAULT, timestamper);
}

@SuppressFBWarnings("SING_SINGLETON_HAS_NONPRIVATE_CONSTRUCTOR")
final class Singleton {
//
static final Timestamper TIMESTAMPER = Registration.INSTANCE.pending;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ enum MessageType {
private static final Logger log = LoggerFactory.getLogger(BaseUsmMessage.class);

// TODO: sync with systemprobe code
static final NativeLong USM_IOCTL_ID = new NativeLong(0xda7ad09L);;
static final NativeLong USM_IOCTL_ID = new NativeLong(0xda7ad09L);

abstract static class BaseUsmMessage implements UsmMessage {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import datadog.trace.api.ProductActivation;
import datadog.trace.api.UserIdCollectionMode;
import datadog.trace.api.telemetry.WafMetricCollector;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
Expand Down Expand Up @@ -100,8 +101,18 @@ public class AppSecConfigServiceImpl implements AppSecConfigService {
.build()
.adapter(Types.newParameterizedType(Map.class, String.class, Object.class));

@SuppressFBWarnings(
value = "AT_STALE_THREAD_WRITE_OF_PRIMITIVE",
justification =
"The variable is only read and written by the single configuration-poller thread.")
private boolean hasUserWafConfig;

@SuppressFBWarnings(
value = "AT_STALE_THREAD_WRITE_OF_PRIMITIVE",
justification =
"The variable is only read and written by the single configuration-poller thread.")
private boolean defaultConfigActivated;

private final AtomicBoolean subscribedToRulesAndData = new AtomicBoolean();
private final Set<String> usedDDWafConfigKeys =
Collections.newSetFromMap(new ConcurrentHashMap<>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import datadog.trace.api.http.StoredBodySupplier;
import datadog.trace.api.internal.TraceSegment;
import datadog.trace.util.stacktrace.StackTraceEvent;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.Closeable;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -41,6 +42,7 @@

// TODO: different methods to be called by different parts perhaps splitting it would make sense
// or at least create separate interfaces
@SuppressFBWarnings("AT_STALE_THREAD_WRITE_OF_PRIMITIVE")
public class AppSecRequestContext implements DataBundle, Closeable {
private static final Logger log = LoggerFactory.getLogger(AppSecRequestContext.class);

Expand Down
4 changes: 1 addition & 3 deletions dd-java-agent/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

import java.util.concurrent.atomic.AtomicBoolean

plugins {
Expand Down Expand Up @@ -29,7 +28,6 @@ tasks.named("processResources") {
sourceSets {
"main_java6" {
java.srcDirs "${project.projectDir}/src/main/java6"

}
main.resources.srcDir(includedAgentDir)
}
Expand All @@ -43,7 +41,7 @@ tasks.named("compileJava") {
}

dependencies {
main_java6CompileOnly 'de.thetaphi:forbiddenapis:3.8'
main_java6CompileOnly libs.forbiddenapis
testImplementation sourceSets.main_java6.output
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ abstract class InstrumentationSpecification extends DDSpecification implements A
}
}

@SuppressFBWarnings(value = "AT_STALE_THREAD_WRITE_OF_PRIMITIVE", justification = "The variable is accessed only by the test thread in setup and cleanup.")
boolean originalAppSecRuntimeValue

@Shared
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ dependencies {
baseTestImplementation group: 'com.typesafe.akka', name: 'akka-http-spray-json_2.11', version: '10.0.10'

iastTestImplementation project(':dd-java-agent:agent-iast:iast-test-fixtures')
iastTestCompileOnly group: 'de.thetaphi', name: 'forbiddenapis', version: '3.4'
iastTestCompileOnly libs.forbiddenapis
iastTestRuntimeOnly project(':dd-java-agent:instrumentation:jackson-core')
iastTestRuntimeOnly project(':dd-java-agent:instrumentation:jackson-core:jackson-core-2.8')
iastTestRuntimeOnly project(':dd-java-agent:instrumentation:iast-instrumenter')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import datadog.trace.api.iast.Source;
import datadog.trace.api.iast.SourceTypes;
import datadog.trace.api.iast.propagation.PropagationModule;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import net.bytebuddy.asm.Advice;
import scala.collection.Iterator;
import scala.collection.immutable.Seq;
Expand Down Expand Up @@ -61,7 +60,6 @@ public void methodAdvice(MethodTransformer transformer) {
HttpRequestInstrumentation.class.getName() + "$EntityAdvice");
}

@SuppressFBWarnings("BC_IMPOSSIBLE_INSTANCEOF")
@RequiresRequestContext(RequestContextSlot.IAST)
static class RequestHeadersAdvice {
@Advice.OnMethodExit(suppress = Throwable.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import datadog.trace.api.iast.InstrumentationBridge;
import datadog.trace.api.iast.Propagation;
import datadog.trace.api.iast.propagation.PropagationModule;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import net.bytebuddy.asm.Advice;

/** Propagates taint when fetching the {@link HttpRequest} from the {@link RequestContext}. */
Expand All @@ -46,7 +45,6 @@ public void methodAdvice(MethodTransformer transformer) {
RequestContextInstrumentation.class.getName() + "$GetRequestAdvice");
}

@SuppressFBWarnings("BC_IMPOSSIBLE_INSTANCEOF")
@RequiresRequestContext(RequestContextSlot.IAST)
static class GetRequestAdvice {
@Advice.OnMethodExit(suppress = Throwable.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
import datadog.trace.api.iast.SourceTypes;
import datadog.trace.api.iast.propagation.PropagationModule;
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import scala.Tuple1;
import scala.compat.java8.JFunction1;

public class TaintRequestFunction implements JFunction1<Tuple1<HttpRequest>, Tuple1<HttpRequest>> {
public static final TaintRequestFunction INSTANCE = new TaintRequestFunction();

@Override
@SuppressFBWarnings("BC_IMPOSSIBLE_INSTANCEOF")
public Tuple1<HttpRequest> apply(Tuple1<HttpRequest> v1) {
HttpRequest httpRequest = v1._1();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ testJvmConstraints {
}

dependencies {
testImplementation 'de.thetaphi:forbiddenapis:3.8'
testImplementation libs.forbiddenapis
testImplementation libs.bundles.junit5
testImplementation libs.bundles.jmc
testImplementation libs.commons.math
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.agent.tooling.InstrumenterModule;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Map;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
Expand Down Expand Up @@ -50,9 +49,6 @@ public String[] helperClassNames() {
};
}

@SuppressFBWarnings(
value = "UC_USELESS_OBJECT",
justification = "jvmOptions is the return value of the original method")
public static class PropertiesAugmentationAdvice {
@Advice.OnMethodExit(suppress = Throwable.class)
public static void addJavaagentToGradleDaemonProperties(
Expand Down
Loading
Loading