Skip to content

Commit 9c0e6c5

Browse files
committed
fix: resolve NullAway violations after rebase onto main
- AgentStarterImpl: add @nullable to two ClassFileTransformer.transform methods that can return null, matching the existing pattern on the sibling LaunchHelperClassFileTransformer. - HelperInjector: guard null helpersSource with requireNonNull at the call into HelperClassDefinition.create, which delegates to BytecodeWithUrl.create (rejects null with IllegalArgumentException). The message documents the runtime contract: null helpersSource is only valid when helperClassNames is empty. Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
1 parent c23e9d2 commit 9c0e6c5

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/AgentStarterImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ public void visitMethodInsn(
261261

262262
private static class AgentBuilderDefaultClassFileTransformer implements ClassFileTransformer {
263263

264+
@Nullable
264265
@Override
265266
public byte[] transform(
266267
ClassLoader loader,
@@ -295,6 +296,7 @@ public FieldVisitor visitField(
295296

296297
private static class CallbackRegistrationClassFileTransformer implements ClassFileTransformer {
297298

299+
@Nullable
298300
@Override
299301
public byte[] transform(
300302
ClassLoader loader,

muzzle/src/main/java/io/opentelemetry/javaagent/tooling/HelperInjector.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,11 @@ public HelperInjector(
134134
.map(
135135
className ->
136136
HelperClassDefinition.create(
137-
className, helpersSource, InjectionMode.CLASS_ONLY))
137+
className,
138+
requireNonNull(
139+
helpersSource,
140+
"helpersSource must not be null when helperClassNames is non-empty"),
141+
InjectionMode.CLASS_ONLY))
138142
.collect(toList());
139143

140144
this.helperClassesGenerator = (cl) -> helpers;

0 commit comments

Comments
 (0)