-
Notifications
You must be signed in to change notification settings - Fork 344
Alexeyk/bump spotbugs #11879
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
base: master
Are you sure you want to change the base?
Alexeyk/bump spotbugs #11879
Changes from all commits
e6e7f6e
d3723cc
4d5318a
ba635ad
2133b5e
247f390
ceb58e2
21e5e8d
2809641
2c5f62b
afedd85
b72f8de
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| package datadog.trace.bootstrap.instrumentation.usm; | ||
|
|
||
| import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; | ||
|
|
||
| public interface UsmExtractor { | ||
| void send(UsmMessage message); | ||
|
|
||
|
|
@@ -10,6 +12,9 @@ public static void send(UsmMessage message) { | |
| SUPPLIER.send(message); | ||
| } | ||
|
|
||
| @SuppressFBWarnings( | ||
| value = "USO_UNSAFE_STATIC_METHOD_SYNCHRONIZATION", | ||
| justification = "Agent-internal holder; Class lock does not escape to application code") | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @typotter Please confirm that this suppression is correct. |
||
| public static synchronized void registerIfAbsent(UsmExtractor supplier) { | ||
| if (SUPPLIER == null) { | ||
| SUPPLIER = supplier; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| package datadog.trace.bootstrap.instrumentation.usm; | ||
|
|
||
| import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; | ||
|
|
||
| public interface UsmMessageFactory { | ||
| UsmMessage getCloseMessage(UsmConnection connection); | ||
|
|
||
|
|
@@ -17,6 +19,9 @@ public static UsmMessage getRequestMessage( | |
| return SUPPLIER.getRequestMessage(connection, buffer, bufferOffset, len); | ||
| } | ||
|
|
||
| @SuppressFBWarnings( | ||
| value = "USO_UNSAFE_STATIC_METHOD_SYNCHRONIZATION", | ||
| justification = "Agent-internal holder; Class lock does not escape to application code") | ||
|
Comment on lines
+22
to
+24
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @typotter Please confirm that this suppression is correct. |
||
| public static synchronized void registerIfAbsent(UsmMessageFactory supplier) { | ||
| if (null == SUPPLIER) { | ||
| SUPPLIER = supplier; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,7 @@ | |
| import datadog.trace.bootstrap.instrumentation.api.Tags; | ||
| import datadog.trace.core.DDTraceCoreInfo; | ||
| import datadog.trace.util.TagsHelper; | ||
| import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; | ||
| import java.io.IOException; | ||
| import java.lang.instrument.ClassFileTransformer; | ||
| import java.lang.instrument.Instrumentation; | ||
|
|
@@ -75,6 +76,9 @@ public class DebuggerAgent { | |
| static final AtomicBoolean symDBEnabled = new AtomicBoolean(); | ||
| private static ClassesToRetransformFinder classesToRetransformFinder; | ||
|
|
||
| @SuppressFBWarnings( | ||
| value = "USO_UNSAFE_STATIC_METHOD_SYNCHRONIZATION", | ||
| justification = "Agent-internal class; Class object does not escape to application code") | ||
|
Comment on lines
+79
to
+81
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jpbempel Please confirm that this suppression is correct. |
||
| public static synchronized void run( | ||
| Config config, Instrumentation inst, SharedCommunicationObjects sco) { | ||
| instrumentation = inst; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| import datadog.metrics.api.statsd.StatsDClient; | ||
| import datadog.metrics.impl.statsd.DDAgentStatsDClientManager; | ||
| import datadog.trace.api.Config; | ||
| import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; | ||
|
|
||
| /** implements a StatsD client for internal debugger agent metrics */ | ||
| public class DebuggerMetrics implements StatsDClient { | ||
|
|
@@ -29,6 +30,9 @@ private DebuggerMetrics(Config config) { | |
| } | ||
| } | ||
|
|
||
| @SuppressFBWarnings( | ||
| value = {"USO_UNSAFE_METHOD_SYNCHRONIZATION", "USO_UNSAFE_STATIC_METHOD_SYNCHRONIZATION"}, | ||
| justification = "Agent-internal singleton; neither Class object nor instance monitor escapes") | ||
|
Comment on lines
+33
to
+35
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jpbempel Please confirm that this suppression is correct. |
||
| public static synchronized DebuggerMetrics getInstance(Config config) { | ||
| if (INSTANCE == null) { | ||
| INSTANCE = new DebuggerMetrics(config); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ | |
| import datadog.trace.api.profiling.RecordingDataListener; | ||
| import datadog.trace.api.profiling.RecordingType; | ||
| import datadog.trace.bootstrap.config.provider.ConfigProvider; | ||
| import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; | ||
| import java.io.IOException; | ||
| import java.lang.instrument.Instrumentation; | ||
| import java.lang.ref.WeakReference; | ||
|
|
@@ -95,6 +96,10 @@ public void onNewData(RecordingType type, RecordingData data, boolean handleSync | |
| * Main entry point into profiling Note: this must be reentrant because we may want to start | ||
| * profiling before any other tool, and then attempt to start it again at normal time | ||
| */ | ||
| @SuppressFBWarnings( | ||
| value = "USO_UNSAFE_STATIC_METHOD_SYNCHRONIZATION", | ||
| justification = | ||
| "Agent-internal class; Class object does not escape to app code and lock only guards reentrant one-time profiler startup.") | ||
|
Comment on lines
+99
to
+102
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jbachorik Please confirm that this suppression is correct. |
||
| public static synchronized boolean run(final boolean earlyStart, Instrumentation inst) | ||
| throws IllegalArgumentException, IOException { | ||
| if (profiler == null) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| package datadog.trace.agent.tooling; | ||
|
|
||
| import datadog.instrument.utils.ClassLoaderValue; | ||
| import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; | ||
| import java.util.Arrays; | ||
| import java.util.concurrent.atomic.AtomicLongArray; | ||
| import org.slf4j.Logger; | ||
|
|
@@ -121,6 +122,15 @@ public static void blockInstrumentation(ClassLoader classLoader, int instrumenta | |
| } | ||
|
|
||
| /** Records that the instrumentation is blocked by default. */ | ||
| // Claude: SpotBugs USO_UNSAFE_ACCESSIBLE_OBJECT_SYNCHRONIZATION: should be reviewed by team. | ||
| // The lock object is the non-final 'defaultState' array, which is reassigned in | ||
| // resetDefaultState(); a reset racing with this method could leave threads synchronizing on | ||
| // different array instances, and reads in currentState/updateState are unsynchronized. The field | ||
| // is private so app code can't lock it, but the reassignable-lock smell warrants a look. | ||
| @SuppressFBWarnings( | ||
| value = "USO_UNSAFE_ACCESSIBLE_OBJECT_SYNCHRONIZATION", | ||
| justification = | ||
| "Locks the reassignable 'defaultState' array; private to the agent but lock-object identity can change on reset, so flagged for team review.") | ||
|
Comment on lines
+125
to
+133
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mcculls Please confirm that this suppression is correct.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment is overly verbose - basically this is ok because of how it is called.
Also note that this particular So we could also just remove this method...
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @mcculls I will remove comment and update |
||
| public static void blockInstrumentation(int instrumentationId) { | ||
| int bitIndex = instrumentationId << 1; | ||
| int wordIndex = bitIndex >> ADDRESS_BITS_PER_WORD; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
| import datadog.trace.api.civisibility.events.TestSuiteDescriptor; | ||
| import datadog.trace.api.civisibility.telemetry.tag.TestFrameworkInstrumentation; | ||
| import datadog.trace.util.ConcurrentEnumMap; | ||
| import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; | ||
| import java.util.Collection; | ||
| import java.util.Map; | ||
|
|
||
|
|
@@ -17,6 +18,9 @@ public abstract class TestEventsHandlerHolder { | |
| TestFrameworkInstrumentation, TestEventsHandler<TestSuiteDescriptor, TestDescriptor>> | ||
| HANDLERS = new ConcurrentEnumMap<>(TestFrameworkInstrumentation.class); | ||
|
|
||
| @SuppressFBWarnings( | ||
| value = "USO_UNSAFE_STATIC_METHOD_SYNCHRONIZATION", | ||
| justification = "Holder class not exposed to application code; locking on its Class is safe") | ||
|
Comment on lines
+21
to
+23
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @daniel-mohedano Please confirm that this suppression is correct. |
||
| public static synchronized void start( | ||
| TestFrameworkInstrumentation framework, Collection<LibraryCapability> capabilities) { | ||
| TestEventsHandler<TestSuiteDescriptor, TestDescriptor> handler = HANDLERS.get(framework); | ||
|
|
@@ -29,6 +33,9 @@ public static synchronized void start( | |
| } | ||
|
|
||
| /** Used by instrumentation tests */ | ||
| @SuppressFBWarnings( | ||
| value = "USO_UNSAFE_STATIC_METHOD_SYNCHRONIZATION", | ||
| justification = "Holder class not exposed to application code; locking on its Class is safe") | ||
| public static synchronized void stop(TestFrameworkInstrumentation framework) { | ||
| TestEventsHandler<TestSuiteDescriptor, TestDescriptor> handler = HANDLERS.remove(framework); | ||
| if (handler != null) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
|
|
||
| import datadog.trace.api.civisibility.config.TestIdentifier; | ||
| import datadog.trace.api.civisibility.config.TestSourceData; | ||
| import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; | ||
| import java.util.Collections; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
@@ -24,6 +25,9 @@ private TestDataFactory() {} | |
| private static volatile Map<String, Predicate<TestDescriptor>> | ||
| TEST_DESCRIPTOR_FILTER_BY_ENGINE_ID = Collections.emptyMap(); | ||
|
|
||
| @SuppressFBWarnings( | ||
| value = "USO_UNSAFE_STATIC_METHOD_SYNCHRONIZATION", | ||
| justification = "Holder class not exposed to application code; locking on its Class is safe") | ||
|
Comment on lines
+28
to
+30
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @daniel-mohedano Please confirm that this suppression is correct. |
||
| public static synchronized void register( | ||
| String engineId, | ||
| Function<TestDescriptor, TestIdentifier> testIdentifierFactory, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
| import datadog.trace.api.civisibility.telemetry.tag.TestFrameworkInstrumentation; | ||
| import datadog.trace.bootstrap.ContextStore; | ||
| import datadog.trace.util.ConcurrentEnumMap; | ||
| import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; | ||
| import java.util.Map; | ||
| import org.junit.platform.engine.TestDescriptor; | ||
| import org.junit.platform.engine.TestEngine; | ||
|
|
@@ -22,6 +23,9 @@ public abstract class TestEventsHandlerHolder { | |
| private static volatile ContextStore<TestDescriptor, TestExecutionTracker> | ||
| EXECUTION_TRACKER_STORE; | ||
|
|
||
| @SuppressFBWarnings( | ||
| value = "USO_UNSAFE_STATIC_METHOD_SYNCHRONIZATION", | ||
| justification = "Holder class not exposed to application code; locking on its Class is safe") | ||
|
Comment on lines
+26
to
+28
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @daniel-mohedano Please confirm that this suppression is correct. |
||
| public static synchronized void setExecutionTrackerStore( | ||
| ContextStore<TestDescriptor, TestExecutionTracker> executionTrackerStore) { | ||
| if (EXECUTION_TRACKER_STORE == null) { | ||
|
|
@@ -44,6 +48,9 @@ public static TestExecutionTracker getExecutionTracker(TestDescriptor testDescri | |
| } | ||
| } | ||
|
|
||
| @SuppressFBWarnings( | ||
| value = "USO_UNSAFE_STATIC_METHOD_SYNCHRONIZATION", | ||
| justification = "Holder class not exposed to application code; locking on its Class is safe") | ||
|
Comment on lines
+51
to
+53
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @daniel-mohedano Please confirm that this suppression is correct. |
||
| public static synchronized void start( | ||
| TestEngine testEngine, | ||
| ContextStore<TestDescriptor, DDTestSuite> suiteStore, | ||
|
|
@@ -62,6 +69,9 @@ public static synchronized void start( | |
| } | ||
|
|
||
| /** Used by instrumentation tests */ | ||
| @SuppressFBWarnings( | ||
| value = "USO_UNSAFE_STATIC_METHOD_SYNCHRONIZATION", | ||
| justification = "Holder class not exposed to application code; locking on its Class is safe") | ||
|
Comment on lines
+72
to
+74
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @daniel-mohedano Please confirm that this suppression is correct. |
||
| public static synchronized void stop() { | ||
| for (TestEventsHandler<TestDescriptor, TestDescriptor> handler : HANDLERS.values()) { | ||
| handler.close(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| import datadog.trace.api.sampling.SamplingMechanism; | ||
| import datadog.trace.bootstrap.instrumentation.api.AgentSpan; | ||
| import datadog.trace.bootstrap.instrumentation.api.AgentTracer; | ||
| import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; | ||
| import java.lang.reflect.Field; | ||
| import java.util.Map; | ||
| import org.apache.spark.launcher.SparkAppHandle; | ||
|
|
@@ -30,6 +31,10 @@ public class SparkLauncherListener implements SparkAppHandle.Listener { | |
| private static long submittedTimeMs = 0L; | ||
| private static long runningTimeMs = 0L; | ||
|
|
||
| @SuppressFBWarnings( | ||
| value = "USO_UNSAFE_STATIC_METHOD_SYNCHRONIZATION", | ||
| justification = | ||
| "Listener class not exposed to application code; locking on its Class is safe") | ||
|
Comment on lines
+34
to
+37
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @aboitreaud Please confirm that this suppression is correct. |
||
| public static synchronized void createLauncherSpan(Object launcher) { | ||
| if (launcherSpan != null) { | ||
| return; | ||
|
|
@@ -70,6 +75,10 @@ public static synchronized void createLauncherSpan(Object launcher) { | |
| } | ||
| } | ||
|
|
||
| @SuppressFBWarnings( | ||
| value = "USO_UNSAFE_STATIC_METHOD_SYNCHRONIZATION", | ||
| justification = | ||
| "Listener class not exposed to application code; locking on its Class is safe") | ||
| public static synchronized void finishSpan(boolean isError, String errorMessage) { | ||
| AgentSpan span = launcherSpan; | ||
| if (span == null) { | ||
|
|
@@ -85,6 +94,10 @@ public static synchronized void finishSpan(boolean isError, String errorMessage) | |
| launcherSpan = null; | ||
| } | ||
|
|
||
| @SuppressFBWarnings( | ||
| value = "USO_UNSAFE_STATIC_METHOD_SYNCHRONIZATION", | ||
| justification = | ||
| "Listener class not exposed to application code; locking on its Class is safe") | ||
| public static synchronized void finishSpanWithThrowable(Throwable throwable) { | ||
| AgentSpan span = launcherSpan; | ||
| if (span == null) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,9 @@ public abstract class TestEventsHandlerHolder { | |
|
|
||
| private static ContextStore<ITestResult, DDTest> TEST_STORE; | ||
|
|
||
| @SuppressFBWarnings( | ||
| value = "USO_UNSAFE_STATIC_METHOD_SYNCHRONIZATION", | ||
| justification = "Holder class not exposed to application code; locking on its Class is safe") | ||
|
Comment on lines
+18
to
+20
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @daniel-mohedano Please confirm that this suppression is correct. |
||
| public static synchronized void setContextStore(ContextStore<ITestResult, DDTest> testStore) { | ||
| if (TEST_STORE == null) { | ||
| TEST_STORE = testStore; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
| import datadog.trace.api.civisibility.execution.TestExecutionTracker; | ||
| import datadog.trace.api.civisibility.telemetry.tag.TestFrameworkInstrumentation; | ||
| import datadog.trace.api.time.SystemTimeSource; | ||
| import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; | ||
| import java.lang.reflect.Method; | ||
| import java.util.Collection; | ||
| import java.util.Collections; | ||
|
|
@@ -28,6 +29,10 @@ public class DatadogWeaverReporter { | |
| private static volatile TestEventsHandler<TestSuiteDescriptor, TestDescriptor> | ||
| TEST_EVENTS_HANDLER; | ||
|
|
||
| @SuppressFBWarnings( | ||
| value = "USO_UNSAFE_STATIC_METHOD_SYNCHRONIZATION", | ||
| justification = | ||
| "Reporter class not exposed to application code; locking on its Class is safe") | ||
|
Comment on lines
+32
to
+35
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @daniel-mohedano Please confirm that this suppression is correct. |
||
| public static synchronized void start() { | ||
| if (TEST_EVENTS_HANDLER == null) { | ||
| TEST_EVENTS_HANDLER = | ||
|
|
@@ -37,6 +42,10 @@ public static synchronized void start() { | |
| } | ||
|
|
||
| /** Used by instrumentation tests */ | ||
| @SuppressFBWarnings( | ||
| value = "USO_UNSAFE_STATIC_METHOD_SYNCHRONIZATION", | ||
| justification = | ||
| "Reporter class not exposed to application code; locking on its Class is safe") | ||
|
Comment on lines
+45
to
+48
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @daniel-mohedano Please confirm that this suppression is correct. |
||
| public static synchronized void stop() { | ||
| if (TEST_EVENTS_HANDLER != null) { | ||
| TEST_EVENTS_HANDLER.close(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.