-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add NullAway to javaagent-tooling and javaagent #17719
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: main
Are you sure you want to change the base?
Changes from all commits
0fc541f
c23e9d2
9c0e6c5
2616376
7a59e56
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,6 @@ | ||
| plugins { | ||
| id("otel.java-conventions") | ||
| id("otel.nullaway-conventions") | ||
| id("otel.publish-conventions") | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| package io.opentelemetry.javaagent.tooling; | ||
|
|
||
| import static java.util.Arrays.asList; | ||
| import static java.util.Collections.emptyMap; | ||
|
|
||
| import io.opentelemetry.api.GlobalOpenTelemetry; | ||
| import io.opentelemetry.instrumentation.config.bridge.ConfigPropertiesBackedConfigProvider; | ||
|
|
@@ -16,6 +17,7 @@ | |
| import io.opentelemetry.sdk.autoconfigure.SdkAutoconfigureAccess; | ||
| import io.opentelemetry.sdk.autoconfigure.internal.AutoConfigureUtil; | ||
| import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; | ||
| import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties; | ||
| import io.opentelemetry.sdk.common.CompletableResultCode; | ||
|
|
||
| public final class OpenTelemetryInstaller { | ||
|
|
@@ -36,15 +38,17 @@ public static AutoConfiguredOpenTelemetrySdk installOpenTelemetrySdk( | |
| .build(); | ||
| OpenTelemetrySdk sdk = autoConfiguredSdk.getOpenTelemetrySdk(); | ||
| ConfigProperties configProperties = AutoConfigureUtil.getConfig(autoConfiguredSdk); | ||
| boolean declarativeConfigUsed = configProperties == null; | ||
|
|
||
| if (!declarativeConfigUsed) { | ||
| if (configProperties != null) { | ||
| // Provide a fake declarative configuration based on config properties | ||
| // so that declarative configuration API can be used everywhere | ||
| sdk = | ||
| new ExtendedOpenTelemetrySdkWrapper( | ||
| sdk, ConfigPropertiesBackedConfigProvider.create(configProperties)); | ||
| AgentDistributionConfig.set(AgentDistributionConfig.fromConfigProperties(configProperties)); | ||
| } else { | ||
| // Declarative config path: no ConfigProperties available, use empty defaults | ||
| configProperties = DefaultConfigProperties.createFromMap(emptyMap()); | ||
|
Member
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. [General] Behavior change worth confirming: previously, in declarative-config mode, the returned Any extension that disambiguated declarative mode via |
||
| } | ||
|
|
||
| setForceFlush(sdk); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[General] Setting the ThreadLocal to
NOPhere can silently corrupt outer state.beforeDefineClassnow returnsDefineClassContextImpl.NOPfor the J9ROMCLASSCOOKIE path without callingenter()(so the ThreadLocal is not pushed). ButafterDefineClasshas been simplified to always callcontext.exit(), soNOP.exit()runs — and sinceNOP.previousisnull, this line writesNOPintodefineClassContext.In a nested scenario (outer
beforeDefineClasstriggers a nested class definition viaClass.forNameduring super-type resolution, and the nested class hits the J9 path), the innerNOP.exit()overwrites the outer context withNOP. Between that point and the outerafterDefineClass,isFailedClass()/getSuperTypes()will readNOPinstead of the outer context.Consider making
exit()a no-op onNOP(e.g. early-return whenthis == NOP), or restore the previous behavior of skippingexit()whenbeforeDefineClassreturned the no-op sentinel.