Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
3866a54
Bump Groovy: 3.0.24 -> 4.0.28
AlexeyKuznetsov-DD Oct 13, 2025
f128d3c
WIP
AlexeyKuznetsov-DD Oct 13, 2025
9dffccd
WIP 2
AlexeyKuznetsov-DD Oct 13, 2025
d88be22
WIP 3
AlexeyKuznetsov-DD Oct 13, 2025
51da522
WIP 4
AlexeyKuznetsov-DD Oct 13, 2025
fb2f81e
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Oct 21, 2025
af5d06d
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Oct 21, 2025
765fd92
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Oct 22, 2025
1ca9595
Spotbugs tweaks.
AlexeyKuznetsov-DD Oct 22, 2025
226a2c5
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Oct 22, 2025
a429354
WIP tweaks
AlexeyKuznetsov-DD Oct 23, 2025
ad15665
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Oct 25, 2025
8fdf26b
Fixed Groovy ambiguity. Tweaked
AlexeyKuznetsov-DD Oct 25, 2025
e687aa9
Build workaround.
AlexeyKuznetsov-DD Oct 25, 2025
6da67dd
Fixed Groovy compiler settings.
AlexeyKuznetsov-DD Oct 25, 2025
69ccd4a
Fixed Groovy compiler settings.
AlexeyKuznetsov-DD Oct 25, 2025
7c04a1c
Fixed Groovy compiler settings.
AlexeyKuznetsov-DD Oct 25, 2025
5b73524
Refactored Groovy compiler config. Disabled module `:dd-smoke-tests:s…
AlexeyKuznetsov-DD Oct 25, 2025
7a0bd21
Tests fixed.
AlexeyKuznetsov-DD Oct 25, 2025
e863a91
Revert some code. Ignore tests.
AlexeyKuznetsov-DD Oct 26, 2025
76dcdd8
Fixed tests. Ignore tests.
AlexeyKuznetsov-DD Oct 26, 2025
ca64f39
Ignore tests.
AlexeyKuznetsov-DD Oct 26, 2025
27c46bc
Ignore tests
AlexeyKuznetsov-DD Oct 26, 2025
ba98146
Ignore tests.
AlexeyKuznetsov-DD Oct 26, 2025
2b04db3
Tweaking Groovy setup.
AlexeyKuznetsov-DD Oct 26, 2025
612eae0
Tweaking build.
AlexeyKuznetsov-DD Oct 27, 2025
0196afe
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 5, 2025
0cf4bb1
Fixed Groovy compiler settings.
AlexeyKuznetsov-DD Nov 5, 2025
97a76dc
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 6, 2025
d3d8f43
Fixed build.
AlexeyKuznetsov-DD Nov 6, 2025
be3215f
Fixed build.
AlexeyKuznetsov-DD Nov 6, 2025
7ebb3db
Fixed tests.
AlexeyKuznetsov-DD Nov 6, 2025
d03fee4
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 7, 2025
bf02b3f
Fixed tests.
AlexeyKuznetsov-DD Nov 7, 2025
9a038e9
Fixed tests.
AlexeyKuznetsov-DD Nov 7, 2025
7b7df33
JUnit works only with Groovy 4.0.26 (Same as Spock)
AlexeyKuznetsov-DD Nov 7, 2025
e9128d5
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 7, 2025
f3152e3
Merged with master
AlexeyKuznetsov-DD Nov 10, 2025
df4602c
Fixed `:dd-smoke-tests:gradle` module tests.
AlexeyKuznetsov-DD Nov 10, 2025
aa5bcbf
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 12, 2025
9352e18
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 12, 2025
aa1c447
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 13, 2025
d5952a9
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 17, 2025
c05bf3c
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 18, 2025
0c6a9a4
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 18, 2025
4fedc8f
Refactored groovy and spock configuration to plugin.
AlexeyKuznetsov-DD Nov 20, 2025
7d882b5
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 20, 2025
a9856a1
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 20, 2025
17998ec
Added missing objenesis
AlexeyKuznetsov-DD Nov 21, 2025
6a4b28a
Fixed tests and refactored configurations.
AlexeyKuznetsov-DD Nov 21, 2025
8b8ba20
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 21, 2025
6d030ce
All spock dependencies should be in `groovySpock` config.
AlexeyKuznetsov-DD Nov 21, 2025
314ba85
Minor fix
AlexeyKuznetsov-DD Nov 21, 2025
5af7b01
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 21, 2025
a647df7
Cleanup.
AlexeyKuznetsov-DD Nov 21, 2025
7ff5d91
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 24, 2025
c692c4b
Bump Groovy and Spock versions.
AlexeyKuznetsov-DD Nov 24, 2025
6c13302
Reverted version of Groovy and Spock, to prev version.
AlexeyKuznetsov-DD Nov 24, 2025
d1c1df6
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 26, 2025
4327f62
Minor
AlexeyKuznetsov-DD Nov 26, 2025
31ebf5f
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Dec 12, 2025
b284f24
Fixed false-positive FindBugs warning.
AlexeyKuznetsov-DD Dec 12, 2025
b47a10c
Latest versions of Groovy
AlexeyKuznetsov-DD Dec 12, 2025
ba933b1
latest deps updated
AlexeyKuznetsov-DD Dec 12, 2025
925dc31
Merged with master. Replaced `grrovySpock` plugin with direct imports.
AlexeyKuznetsov-DD Dec 13, 2025
f5167a7
Fixed failed tests
AlexeyKuznetsov-DD Dec 13, 2025
3345306
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Dec 15, 2025
2981bdc
Minor
AlexeyKuznetsov-DD Dec 15, 2025
e0bf985
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Dec 17, 2025
5c4823a
Fixed gradle smoke tests.
AlexeyKuznetsov-DD Dec 17, 2025
15d93d0
Minor
AlexeyKuznetsov-DD Dec 17, 2025
adced87
Merge remote-tracking branch 'origin/master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Dec 18, 2025
71c1ad1
Merge remote-tracking branch 'origin/master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Dec 19, 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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import freemarker.core.InvalidReferenceException
import freemarker.template.Template
import freemarker.template.TemplateException
import freemarker.template.TemplateExceptionHandler
import groovy.transform.CompileStatic
import org.opentest4j.AssertionFailedError
import org.skyscreamer.jsonassert.JSONAssert
import org.skyscreamer.jsonassert.JSONCompareMode
Expand Down Expand Up @@ -367,6 +368,7 @@ abstract class CiVisibilityTestUtils {
return compiledPaths
}

@CompileStatic // Workaround for Groovy 4 to not produce false-positive FindBugs warning `UPM_UNCALLED_PRIVATE_METHOD`.
private static DynamicPath path(String rawPath, boolean unique = true) {
return new DynamicPath(rawPath, JsonPath.compile(rawPath), unique)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.datadog.iast.taint

import datadog.trace.test.util.DDSpecification
import groovy.transform.CompileStatic
import spock.lang.IgnoreIf
import spock.lang.Shared

Expand Down Expand Up @@ -51,6 +52,7 @@ class HashCodeTest extends DDSpecification {
}
}

@CompileStatic // Workaround to avoid NPE in Groovy 4 `org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache()` method.
private static List<Integer> genHashCodes(final int n) {
(1..n).collect {
System.identityHashCode(Double.toString(Math.random()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ package com.datadog.iast.taint

import static TaintedMap.POSITIVE_MASK

import groovy.transform.CompileStatic

/**
* Generate objects to test {@link TaintedMap}.
*/
@CompileStatic // Workaround to avoid java.lang.AbstractMethodError with Groovy 4.
class ObjectGen {

final int capacity
Expand Down Expand Up @@ -36,7 +39,8 @@ class ObjectGen {
}
}

def genBucket(int nObjects, Closure<Boolean> isValid) {
// Have to return specific type to avoid java.lang.AbstractMethodError with Groovy 4.
List<Object> genBucket(int nObjects, Closure<Boolean> isValid) {
assert nObjects > 0
while (true) {
for (int i = 0; i < capacity; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -787,8 +787,8 @@ class WAFModuleSpecification extends DDSpecification {
stackTrace.language == 'java'
stackTrace.message == 'Exploit detected'
stackTrace.frames.size() >= 1
stackTrace.frames[0].class_name == 'org.codehaus.groovy.runtime.callsite.CallSiteArray'
stackTrace.frames[0].function == 'defaultCall'
stackTrace.frames[0].class_name == 'org.codehaus.groovy.vmplugin.v8.IndyInterface' // With Groovy 3 it was 'org.codehaus.groovy.runtime.callsite.CallSiteArray'
stackTrace.frames[0].function == 'fromCache' // With Groovy 3 it was 'defaultCall'
}

void 'redaction with default settings'() {
Expand Down
2 changes: 2 additions & 0 deletions dd-java-agent/instrumentation/aerospike-4.0/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ dependencies {
tasks.withType(Test).configureEach {
usesService(testcontainersLimit)
}

configureGroovyCompiler(21, "compileLatestDepTestGroovy", "compileLatestDepForkedTestGroovy")
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class CompletableFutureTest extends InstrumentationSpecification {
// The parent and the child spans can finish out of order since they run
// on different threads concurrently
trace(2) {
def pIndex = span(0).isRootSpan() ? 0 : 1
def pIndex = span(0).checkRootSpan() ? 0 : 1
def cIndex = 1 - pIndex
basicSpan(it, pIndex, "parent")
basicSpan(it, cIndex, "child", span(pIndex))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class CrossedContextTest extends InstrumentationSpecification {
then:
for (List<DDSpan> trace : TEST_WRITER) {
assert trace.size() == 2
DDSpan parent = trace.find({ it.isRootSpan() })
DDSpan parent = trace.find({ it.checkRootSpan() })
assert null != parent
DDSpan child = trace.find({ it.getParentId() == parent.getSpanId() })
assert null != child
Expand Down Expand Up @@ -121,7 +121,7 @@ class CrossedContextTest extends InstrumentationSpecification {
then:
for (List<DDSpan> trace : TEST_WRITER) {
assert trace.size() == 2
DDSpan parent = trace.find({ it.isRootSpan() })
DDSpan parent = trace.find({ it.checkRootSpan() })
assert null != parent
DDSpan child = trace.find({ it.getParentId() == parent.getSpanId() })
assert null != child
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ class RecursiveThreadPoolPropagationTest extends InstrumentationSpecification {
List<DDSpan> trace = TEST_WRITER.get(0)
assert trace.size() == depth
for (DDSpan span : sortByDepth(trace)) {
orphanCount += span.isRootSpan() ? 1 : 0
orphanCount += span.checkRootSpan() ? 1 : 0
assert String.valueOf(i++) == span.getOperationName()
}
assert orphanCount == 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ class DirectAllocationTrackingTest extends InstrumentationSpecification {
def sample = directAllocations.find({ it.getEventType().name.equals("datadog.DirectAllocationSample")})
sample.getLong("allocated") == 20
sample.getString("source") == "MMAP"
sample.getString("allocatingClass") == "org.codehaus.groovy.runtime.callsite.PlainObjectMetaMethodSite"
sample.getString("allocatingClass") == "org.codehaus.groovy.vmplugin.v8.IndyInterface" // With Groovy 3 it was "org.codehaus.groovy.runtime.callsite.PlainObjectMetaMethodSite"
sample.getLong("spanId") == expectedSpanId.get()
def total = directAllocations.find({ it.getEventType().name.equals("datadog.DirectAllocationTotal")})
total.getLong("allocated") == 20
total.getString("source") == "MMAP"
total.getString("allocatingClass") == "org.codehaus.groovy.runtime.callsite.PlainObjectMetaMethodSite"
total.getString("allocatingClass") == "org.codehaus.groovy.vmplugin.v8.IndyInterface" // With Groovy 3 it was "org.codehaus.groovy.runtime.callsite.PlainObjectMetaMethodSite"

cleanup:
recording.close()
Expand All @@ -80,12 +80,12 @@ class DirectAllocationTrackingTest extends InstrumentationSpecification {
def sample = directAllocations.find({ it.getEventType().name.equals("datadog.DirectAllocationSample")})
sample.getLong("allocated") == 10
sample.getString("source") == "ALLOCATE_DIRECT"
sample.getString("allocatingClass") == "java_nio_ByteBuffer\$allocateDirect"
sample.getString("allocatingClass") == "org.codehaus.groovy.vmplugin.v8.IndyInterface" // With Groovy 3 it was "java_nio_ByteBuffer\$allocateDirect"
sample.getLong("spanId") == expectedSpanId.get()
def total = directAllocations.find({ it.getEventType().name.equals("datadog.DirectAllocationTotal")})
total.getLong("allocated") == 10
total.getString("source") == "ALLOCATE_DIRECT"
total.getString("allocatingClass") == "java_nio_ByteBuffer\$allocateDirect"
total.getString("allocatingClass") == "org.codehaus.groovy.vmplugin.v8.IndyInterface"// With Groovy 3 it was "java_nio_ByteBuffer\$allocateDirect"

cleanup:
recording.close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ tasks.named("compileMain_java11Java", JavaCompile) {
configureCompiler(it, 11, JavaVersion.VERSION_1_8)
}

configureGroovyCompiler(11,
"compileTestGroovy",
"compileJetty11TestGroovy",
"compileLatestDepTestGroovy",
"compileJetty10LatestDepTestGroovy"
)

dependencies {
main_java11CompileOnly group: 'org.eclipse.jetty', name: 'jetty-client', version: '10.0.0'
main_java11Implementation(project(':dd-java-agent:instrumentation:jetty:jetty-client:jetty-client-common')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ tasks.named("compileMain_java17Java", JavaCompile) {
configureCompiler(it, 17, JavaVersion.VERSION_17)
}

configureGroovyCompiler(17, "compileTestGroovy", "compileLatestDepTestGroovy")

configurations.matching { it.name.startsWith('test') || it.name.startsWith('latestDepTest') }.configureEach {
it.resolutionStrategy {
force group: 'org.slf4j', name: 'slf4j-api', version: libs.versions.slf4j.get()
Expand Down
2 changes: 2 additions & 0 deletions dd-java-agent/instrumentation/junit/junit-5.3/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,5 @@ tasks.named("latestDepTest", Test) {
minJavaVersion = JavaVersion.VERSION_17
}
}

configureGroovyCompiler(17, "compileLatestDepTestGroovy")
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,5 @@ tasks.named("latestDepTest", Test) {
minJavaVersion = JavaVersion.VERSION_17
}
}

configureGroovyCompiler(17, "compileLatestDepTestGroovy")
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ dependencies {
latestDepTestImplementation group: 'org.spockframework', name: 'spock-core', version: '2.+'
}

configurations {
testImplementation {
exclude group: 'org.apache.groovy'
}
}

configurations.matching({ it.name.startsWith('test') }).configureEach({
it.resolutionStrategy {
force group: 'org.junit.platform', name: 'junit-platform-launcher', version: libs.versions.junit.platform.get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies {
compileOnly group: 'org.apache.kafka', name: 'kafka-clients', version: '0.11.0.0'
implementation project(':dd-java-agent:instrumentation:kafka:kafka-common')

testImplementation libs.spock.junit4 // This module still needs Spock with JUnit4.
testImplementation(libs.spock.junit4) // This module still needs Spock with JUnit4.
testImplementation group: 'org.apache.kafka', name: 'kafka-clients', version: '0.11.0.0'
testImplementation group: 'org.springframework.kafka', name: 'spring-kafka', version: '1.3.3.RELEASE'
testImplementation group: 'org.springframework.kafka', name: 'spring-kafka-test', version: '1.3.3.RELEASE'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,43 @@ import datadog.trace.api.Trace
import datadog.trace.instrumentation.kotlin.coroutines.CoreKotlinCoroutineTests
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.FlowCollector
import kotlinx.coroutines.flow.channelFlow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.single
import kotlinx.coroutines.launch
import kotlinx.coroutines.withTimeout

// Workaround for Groovy 4 breaking Kotlin SAM conversion for FlowCollector
private suspend inline fun <T> Flow<T>.forEach(crossinline action: suspend (T) -> Unit) = collect(object : FlowCollector<T> {
override suspend fun emit(value: T) = action(value)
})

class KotlinCoroutineTests(dispatcher: CoroutineDispatcher) : CoreKotlinCoroutineTests(dispatcher) {

@Trace
fun tracedAcrossFlows(withModifiedContext: Boolean): Int = runTest {
val producer = flow {
repeat(3) {
tracedChild("produce_$it")
if (withModifiedContext) {
withTimeout(100) {
emit(it)
}
} else {
// Use channelFlow when emitting from modified context (withTimeout) as regular flow doesn't allow it
val producer: Flow<Int> = if (withModifiedContext) {
channelFlow {
repeat(3) {
tracedChild("produce_$it")
withTimeout(100) { send(it) }
}
}
} else {
flow {
repeat(3) {
tracedChild("produce_$it")
emit(it)
}
}
}.flowOn(jobName("producer"))

launch(jobName("consumer")) {
producer.collect {
tracedChild("consume_$it")
}
producer.forEach { tracedChild("consume_$it") }
}

7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ dependencies {

configurations.named("testRuntimeOnly") {
exclude group: 'ch.qos.logback', module: 'logback-classic'
exclude group: 'org.codehaus.groovy', module: 'groovy-servlet'
}
configurations.named("webappRuntimeClasspath") {
exclude group: 'ch.qos.logback', module: 'logback-classic'
Expand Down
8 changes: 6 additions & 2 deletions dd-java-agent/instrumentation/ratpack-1.5/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ dependencies {
compileOnly group: 'io.ratpack', name: 'ratpack-core', version: '1.5.0'

testImplementation project(':dd-java-agent:instrumentation:netty:netty-4.1')
testImplementation group: 'io.ratpack', name: 'ratpack-groovy-test', version: '1.5.0'
testImplementation(group: 'io.ratpack', name: 'ratpack-groovy-test', version: '1.5.0') {
exclude group: 'org.codehaus.groovy'
}
testImplementation 'com.sun.activation:jakarta.activation:1.2.2'
testImplementation project(':dd-java-agent:appsec:appsec-test-fixtures')
latestDepTestImplementation group: 'io.ratpack', name: 'ratpack-groovy-test', version: '1.+'
latestDepTestImplementation(group: 'io.ratpack', name: 'ratpack-groovy-test', version: '1.+') {
exclude group: 'org.codehaus.groovy'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ addTestSuiteExtendingForDir("boot2LatestDepForkedTest", "boot2LatestDepTest", "t
addTestSuiteExtendingForDir("boot3ForkedTest", "boot3Test", "test")
addTestSuiteExtendingForDir("latestDepForkedTest", "latestDepTest", "test")

configureGroovyCompiler(17, "compileLatestDepTestGroovy", "compileBoot3TestGroovy")
configureGroovyCompiler(17, "compileLatestDepTestGroovy", "compileBoot3TestGroovy", "compileBoot3ForkedTestGroovy", "compileLatestDepForkedTestGroovy")

dependencies {
implementation project(':dd-java-agent:instrumentation:span-origin')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ tasks.named("latestDepForkedTest", Test) {
}
}

configureGroovyCompiler(11, "compileLatestDepTestGroovy", "compileLatestDepForkedTestGroovy")
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext
import datadog.trace.bootstrap.instrumentation.api.Tags
import datadog.trace.core.DDSpan
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings
import groovy.transform.CompileStatic
import org.eclipse.jetty.http.HttpMethod
import org.eclipse.jetty.http.HttpVersion
import org.eclipse.jetty.server.Handler
Expand Down Expand Up @@ -319,6 +320,7 @@ class TestHttpServer implements AutoCloseable {
this.prefix = prefix.startsWith("/") ? prefix : "/" + prefix
}

@CompileStatic // Groovy 4: workaround to avoid `groovy.lang.MissingMethodException`.
@Override
void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
if (target.startsWith(prefix)) {
Expand Down Expand Up @@ -491,7 +493,7 @@ class TestHttpServer implements AutoCloseable {
}

void send(byte[] body) {
sendWithType(DEFAULT_TYPE, body)
sendWithType(DEFAULT_TYPE, (byte[]) body) // Groovy 4 has stricter coercions rules.
}

void sendWithType(String contentType, byte[] body) {
Expand Down
14 changes: 13 additions & 1 deletion dd-smoke-tests/gradle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,23 @@ plugins {
apply from: "$rootDir/gradle/java.gradle"
description = 'Gradle Daemon Instrumentation Smoke Tests.'

// Gradle 8.14.3 bundles Groovy 3 via `gradleTestKit()`, so we need Spock for Groovy 3 instead of Groovy 4.
// Gradle 9.x bundles Groovy 4, so eventually we can drop this workaround.
configurations.configureEach {
// Exclude Groovy 4. Starting from v4 it has group: `org.apache.groovy`.
exclude group: 'org.apache.groovy'

resolutionStrategy {
// Force Spock for Groovy 3.
force "org.spockframework:spock-core:2.4-groovy-3.0"
}
}

dependencies {
testImplementation gradleTestKit()
testImplementation project(':dd-smoke-tests:backend-mock')
testImplementation project(':internal-api')
testImplementation project(':dd-java-agent:agent-ci-visibility:civisibility-test-fixtures')
testImplementation(project(':dd-java-agent:agent-ci-visibility:civisibility-test-fixtures'))
}

tasks.named("test", Test) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,7 @@ protected static final DDSpan buildSpanImpl(
List<AgentSpanLink> links,
DDSpanContext spanContext) {
DDSpan span = DDSpan.create(instrumentationName, timestampMicro, spanContext, links);
if (span.isLocalRootSpan()) {
if (span.checkLocalRootSpan()) {
EndpointTracker tracker = tracer.onRootSpanStarted(span);
if (tracker != null) {
span.setEndpointTracker(tracker);
Expand Down
6 changes: 3 additions & 3 deletions dd-trace-core/src/main/java/datadog/trace/core/DDSpan.java
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public boolean isForceKeep() {
*
* @return true if root, false otherwise
*/
public final boolean isRootSpan() {
public final boolean checkRootSpan() {
return context.getParentId() == DDSpanId.ZERO;
}

Expand All @@ -330,7 +330,7 @@ public DDSpan getLocalRootSpan() {
*
* @return {@literal true} if this span is the same as {@linkplain #getLocalRootSpan()}
*/
public boolean isLocalRootSpan() {
public boolean checkLocalRootSpan() {
return getLocalRootSpan().equals(this);
}

Expand Down Expand Up @@ -382,7 +382,7 @@ private boolean isExceptionReplayEnabled() {
boolean captureOnlyRootSpan =
(Config.get().isDebuggerExceptionOnlyLocalRoot()
|| !Config.get().isDebuggerExceptionCaptureIntermediateSpansEnabled());
if (captureOnlyRootSpan && !isLocalRootSpan()) {
if (captureOnlyRootSpan && !checkLocalRootSpan()) {
return false;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,14 @@ class DDSpanTest extends DDCoreSpecification {
new ExtractedContext(DDTraceId.ONE, 2, PrioritySampling.SAMPLER_DROP, "some-origin", propagationTagsFactory.empty(), DATADOG) | _
}

def "isRootSpan() in and not in the context of distributed tracing"() {
def "checkRootSpan() in and not in the context of distributed tracing"() {
setup:
def root = tracer.buildSpan("root").asChildOf((AgentSpanContext) extractedContext).start()
def child = tracer.buildSpan("child").asChildOf(root).start()

expect:
root.isRootSpan() == isTraceRootSpan
!child.isRootSpan()
root.checkRootSpan() == isTraceRootSpan
!child.checkRootSpan()

cleanup:
child.finish()
Expand Down
2 changes: 1 addition & 1 deletion gradle/codenarc.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: "codenarc"

dependencies {
codenarc('org.codenarc:CodeNarc:3.7.0')
codenarc('org.codenarc:CodeNarc:3.7.0-groovy-4.0')
}

codenarc {
Expand Down
Loading