Skip to content

Commit 7f86a88

Browse files
committed
Fix spring-ai plugin: replace Map.of() with JDK 8 API, reset maven.compiler.release
- Replace Map.of() (JDK 9+) with LinkedHashMap in InputMessages.java - Set <maven.compiler.release /> to cancel parent's --release 8, allowing the compiler to resolve java.lang.Record from provided Spring AI classes - Add spring-ai-1.x-plugin to compiler override allowlist
1 parent 17f3da9 commit 7f86a88

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

apm-sniffer/apm-sdk-plugin/spring-plugins/spring-ai-1.x-plugin/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@
3131
<name>spring-ai-1.x-plugin</name>
3232
<url>http://maven.apache.org</url>
3333

34+
<properties>
35+
<!-- Reset to blank to allow compiling against provided Spring AI classes that use
36+
java.lang.Record. The plugin bytecode remains JDK 8 compatible but needs
37+
the full JDK 17+ API surface visible at compile time. -->
38+
<maven.compiler.release />
39+
</properties>
40+
3441
<dependencies>
3542
<dependency>
3643
<groupId>org.springframework.ai</groupId>

apm-sniffer/apm-sdk-plugin/spring-plugins/spring-ai-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/ai/v1/messages/InputMessages.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ public TextPart(String content) {
9393

9494
@Override
9595
public Map<String, Object> toMap() {
96-
return Map.of("type", "text", "content", content != null ? content : "");
96+
Map<String, Object> map = new LinkedHashMap<>();
97+
map.put("type", "text");
98+
map.put("content", content != null ? content : "");
99+
return map;
97100
}
98101
}
99102

@@ -268,4 +271,5 @@ private static List<MessagePart> toolMessageParts(Message message) {
268271

269272
return parts;
270273
}
274+
271275
}

tools/plugin/check-compiler-overrides.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ WORK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd ../.. && pwd)"
3030
ALLOWLIST=(
3131
"bootstrap-plugins/jdk-httpclient-plugin"
3232
"bootstrap-plugins/jdk-http-plugin"
33+
"spring-plugins/spring-ai-1.x-plugin"
3334
)
3435

3536
EXIT_CODE=0

0 commit comments

Comments
 (0)