Skip to content

Commit cf973bf

Browse files
Restored #9435 since even with latest logback Java 21+ tests with virtual threads have a chance to hang on CI. (#10622)
Restored #9435 since even with latest logback Java 21+ tests with virtual threads have a chance to hang on CI. Co-authored-by: alexey.kuznetsov <alexey.kuznetsov@datadoghq.com>
1 parent 88c2434 commit cf973bf

5 files changed

Lines changed: 37 additions & 14 deletions

File tree

dd-java-agent/instrumentation/java/java-concurrent/java-concurrent-21.0/build.gradle

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
plugins {
2+
id 'idea'
3+
}
4+
15
apply from: "$rootDir/gradle/java.gradle"
2-
apply plugin: 'idea'
6+
// Use slf4j-simple as default; logback has a high chance of getting stuck in a deadlock on CI.
7+
apply from: "$rootDir/gradle/slf4j-simple.gradle"
38

49
testJvmConstraints {
510
minJavaVersion = JavaVersion.VERSION_21
@@ -48,8 +53,5 @@ tasks.named("check") {
4853
}
4954

5055
dependencies {
51-
// Use latest logback for Java 21+ tests with better virtual thread support.
52-
testImplementation(libs.logback.classic.latest)
53-
5456
testImplementation project(':dd-java-agent:instrumentation:datadog:tracing:trace-annotation')
5557
}

dd-java-agent/instrumentation/java/java-concurrent/java-concurrent-25.0/build.gradle

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ plugins {
33
}
44

55
apply from: "$rootDir/gradle/java.gradle"
6+
// Use slf4j-simple as default; logback has a high chance of getting stuck in a deadlock on CI.
7+
apply from: "$rootDir/gradle/slf4j-simple.gradle"
68

79
muzzle {
810
pass {
@@ -15,8 +17,3 @@ idea {
1517
jdkName = '25'
1618
}
1719
}
18-
19-
dependencies {
20-
// Use latest logback for Java 21+ tests with better virtual thread support.
21-
testImplementation(libs.logback.classic.latest)
22-
}

dd-java-agent/instrumentation/java/java-lang/java-lang-21.0/build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ plugins {
33
}
44

55
apply from: "$rootDir/gradle/java.gradle"
6+
// Use slf4j-simple as default; logback has a high chance of getting stuck in a deadlock on CI.
7+
apply from: "$rootDir/gradle/slf4j-simple.gradle"
68

79
testJvmConstraints {
810
minJavaVersion = JavaVersion.VERSION_21
@@ -26,8 +28,5 @@ tasks.named("compileTestJava", JavaCompile) {
2628
}
2729

2830
dependencies {
29-
// Use latest logback for Java 21+ tests with better virtual thread support.
30-
testImplementation(libs.logback.classic.latest)
31-
3231
testImplementation project(':dd-java-agent:instrumentation:datadog:tracing:trace-annotation')
3332
}

gradle/libs.versions.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ lz4 = "1.7.1"
5757
# Logging
5858
slf4j = "1.7.30"
5959
logback = "1.2.13" # required by Java 8 modules.
60-
logback-latest = "1.5.28" # recommended for Java 11+ modules.
6160

6261
# JSON
6362
jackson = "2.20.0"
@@ -135,7 +134,6 @@ lz4 = { module = "org.lz4:lz4-java", version.ref = "lz4" }
135134

136135
# Logging
137136
logback-classic = { module = "ch.qos.logback:logback-classic", version.ref = "logback" }
138-
logback-classic-latest = { module = "ch.qos.logback:logback-classic", version.ref = "logback-latest" }
139137
logback-core = { module = "ch.qos.logback:logback-core", version.ref = "logback" }
140138
log4j-over-slf4j = { module = "org.slf4j:log4j-over-slf4j", version.ref = "slf4j" }
141139
jcl-over-slf4j = { module = "org.slf4j:jcl-over-slf4j", version.ref = "slf4j" }

gradle/slf4j-simple.gradle

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Apply this script when `slf4j-simple` should be used instead of `logback`.
2+
3+
configurations.configureEach { cfg ->
4+
def name = cfg.name
5+
6+
if (name.containsIgnoreCase("test")) {
7+
// Exclude Logback from all test-like runtimeClasspath configurations.
8+
if (name.endsWithIgnoreCase("runtimeClasspath")) {
9+
cfg.exclude group: "ch.qos.logback"
10+
}
11+
12+
// Add slf4j-simple to all test-like runtimeOnly configurations.
13+
if (name.endsWithIgnoreCase("runtimeOnly")) {
14+
project.dependencies.add(name, "org.slf4j:slf4j-simple:${libs.versions.slf4j.get()}")
15+
}
16+
}
17+
}
18+
19+
// Configure `slf4j-simple` logger.
20+
tasks.withType(Test).configureEach {
21+
jvmArgs += [
22+
"-Dorg.slf4j.simpleLogger.defaultLogLevel=debug",
23+
"-Dorg.slf4j.simpleLogger.showThreadName=true",
24+
"-Dorg.slf4j.simpleLogger.showDateTime=true",
25+
"-Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss.SSS"
26+
]
27+
}

0 commit comments

Comments
 (0)