Skip to content

Commit bccddcb

Browse files
committed
fix: call-instrumentation-site test due to the appearance of SequenceCollection::getFirst in JDK 21
1 parent 7a191a3 commit bccddcb

File tree

1 file changed

+4
-1
lines changed
  • buildSrc/call-site-instrumentation-plugin/src/test/groovy/datadog/trace/plugin/csi/impl/assertion

1 file changed

+4
-1
lines changed

buildSrc/call-site-instrumentation-plugin/src/test/groovy/datadog/trace/plugin/csi/impl/assertion/AssertBuilder.groovy

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ class AssertBuilder<C extends CallSiteAssert> {
5959
return [null, null]
6060
}
6161
final isEnabled = type.getMethodsByName('isEnabled').first()
62-
final returnStatement = isEnabled.body.get().statements.first.get().asReturnStmt()
62+
// JavaParser's NodeList has method getFirst() returning an Optional, however with Java 21's
63+
// SequencedCollection, Groovy picks the getFirst() that returns the object itself.
64+
// Using `first()` rather than `first` picks the groovy method instead, fixing the situation.
65+
final returnStatement = isEnabled.body.get().statements.first().asReturnStmt()
6366
final enabledMethodCall = returnStatement.expression.get().asMethodCallExpr()
6467
final enabled = resolveMethod(enabledMethodCall)
6568
final enabledArgs = enabledMethodCall.getArguments().collect { it.asStringLiteralExpr().asString() }.toSet()

0 commit comments

Comments
 (0)