Skip to content

Commit e72c08b

Browse files
committed
More Java 25 support fixes
1 parent 95d527d commit e72c08b

File tree

5 files changed

+24
-21
lines changed

5 files changed

+24
-21
lines changed

agent/src/main/java/com/appland/appmap/reflect/HttpHeaders.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ default Enumeration<String> getHeaderNames() {
3232

3333
/**
3434
* Non-standard utility method. Retrieves all headers.
35+
* Header names are normalized to lowercase since HTTP headers are case-insensitive.
3536
*/
3637
default Map<String, String> getHeaders() {
3738
HashMap<String, String> headers = new HashMap<>();
3839

3940
for (Enumeration<String> e = getHeaderNames(); e.hasMoreElements();) {
4041
String headerName = (String) e.nextElement();
41-
headers.put(headerName, this.getHeader(headerName));
42+
headers.put(headerName.toLowerCase(), this.getHeader(headerName));
4243
}
4344

4445
return headers;

agent/test/intellij/intellij.bats

100644100755
File mode changed.

agent/test/petclinic/petclinic-tests.bats

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ run_petclinic_test() {
4343
run cat ./tmp/appmap/junit/org_springframework_samples_petclinic_${TEST_NAME}_testOwnerDetails.appmap.json
4444
assert_success
4545

46-
# Thread 1 is the test runner's main thread. Check to make sure that parent_id
47-
# of the "return" event matches the id of the "call" event.
48-
assert_json_eq '.events | map(select(.thread_id == 1)) | ((.[0].event == "call" and .[1].event == "return") and (.[1].parent_id == .[0].id))' "true"
46+
# Find the test runner's main thread (the one with testOwnerDetails method).
47+
# Check to make sure that parent_id of the "return" event matches the id of the "call" event.
48+
# Note: In Java 21 the main thread is typically thread 1, but in Java 25 it can be thread 3.
49+
local main_thread_id=$(jq -r '[.events[] | select(.method_id == "testOwnerDetails")][0].thread_id' ./tmp/appmap/junit/org_springframework_samples_petclinic_${TEST_NAME}_testOwnerDetails.appmap.json)
50+
assert_json_eq ".events | map(select(.thread_id == ${main_thread_id})) | ((.[0].event == \"call\" and .[1].event == \"return\") and (.[1].parent_id == .[0].id))" "true"
4951
}
5052

5153
@test "extra properties in appmap.yml are ignored when config is loaded" {

agent/test/petclinic/petclinic.bats

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ setup() {
211211
assert_success
212212
stop_recording
213213

214-
assert_json_eq '.events[] | .http_server_response | .headers["Content-Type"]' "text/html;charset=UTF-8"
214+
# HTTP headers are case-insensitive and are normalized to lowercase
215+
assert_json_eq '.events[] | .http_server_response | .headers["content-type"]' "text/html;charset=UTF-8"
215216
}
216217

217218
@test "recordings capture elapsed time" {

agent/test/test-frameworks/build.gradle

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ def addAgentArgs = [
3636
]
3737

3838
task test_junit(type: Test) {
39+
testClassesDirs = sourceSets.test.output.classesDirs
40+
classpath = sourceSets.test.runtimeClasspath
41+
3942
testLogging {
4043
events TestLogEvent.STANDARD_OUT
4144
}
@@ -44,6 +47,9 @@ task test_junit(type: Test) {
4447
}
4548

4649
task test_testng(type: Test) {
50+
testClassesDirs = sourceSets.test.output.classesDirs
51+
classpath = sourceSets.test.runtimeClasspath
52+
4753
useTestNG()
4854
testLogging {
4955
showStandardStreams = true
@@ -57,21 +63,14 @@ task test_testng(type: Test) {
5763
def jdk8Dependency = 'org.testng:testng:7.5.1'
5864
def jdk11Dependency = 'org.testng:testng:7.9.0'
5965

60-
tasks.register('setTestDependencies') {
61-
doLast {
62-
def jdkVersion = javaToolchains.launcherFor(java.toolchain).get().metadata.languageVersion.asInt()
63-
if (jdkVersion <= 8) {
64-
dependencies {
65-
testImplementation jdk8Dependency
66-
}
67-
} else {
68-
dependencies {
69-
testImplementation jdk11Dependency
70-
}
71-
}
66+
// Add TestNG dependency during configuration phase (not execution phase)
67+
def jdkVersion = System.getProperty('java.version').split('\\.')[0] as Integer
68+
if (jdkVersion <= 8) {
69+
dependencies {
70+
testImplementation jdk8Dependency
71+
}
72+
} else {
73+
dependencies {
74+
testImplementation jdk11Dependency
7275
}
73-
}
74-
75-
tasks.named("compileTestJava") {
76-
dependsOn 'setTestDependencies'
7776
}

0 commit comments

Comments
 (0)