This is an automated email from the ASF dual-hosted git repository. wusheng pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/skywalking-graalvm-distro.git
commit c888e81df03cfa983532e652991ddf6d5dd8ffbe Author: Wu Sheng <[email protected]> AuthorDate: Sun Mar 1 09:21:54 2026 +0800 Fix GraphQL type scanner to handle simple name collisions The simpleNameIndex map was keyed by class simple name, so when multiple classes share the same name (e.g., AlarmMessage exists in core.alarm, core.alarm.grpc, and core.query.type), only the last one was indexed. This caused core.query.type.AlarmMessage to be missing from reflect-config.json, resulting in null String fields in GraphQL alarm query responses. Change the index to map simple name → list of FQCNs so all variants are included in the reflection configuration. --- .../server/buildtools/precompiler/Precompiler.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/build-tools/precompiler/src/main/java/org/apache/skywalking/oap/server/buildtools/precompiler/Precompiler.java b/build-tools/precompiler/src/main/java/org/apache/skywalking/oap/server/buildtools/precompiler/Precompiler.java index 0dc4e27..34320c1 100644 --- a/build-tools/precompiler/src/main/java/org/apache/skywalking/oap/server/buildtools/precompiler/Precompiler.java +++ b/build-tools/precompiler/src/main/java/org/apache/skywalking/oap/server/buildtools/precompiler/Precompiler.java @@ -969,10 +969,15 @@ public class Precompiler { private static List<String> scanGraphQLTypes( ImmutableSet<ClassPath.ClassInfo> allClasses) { - // Build simple name → FQCN index for all SkyWalking classes - Map<String, String> simpleNameIndex = new HashMap<>(); + // Build simple name → list of FQCNs index for all SkyWalking classes. + // Multiple classes can share a simple name (e.g., AlarmMessage exists in + // core.alarm, core.alarm.grpc, and core.query.type packages). + // We include ALL matching classes for reflection to avoid missing the + // graphql-java-tools type resolver's target class. + Map<String, List<String>> simpleNameIndex = new HashMap<>(); for (ClassPath.ClassInfo classInfo : allClasses) { - simpleNameIndex.put(classInfo.getSimpleName(), classInfo.getName()); + simpleNameIndex.computeIfAbsent(classInfo.getSimpleName(), k -> new ArrayList<>()) + .add(classInfo.getName()); } // Parse .graphqls files from classpath @@ -1000,13 +1005,13 @@ public class Precompiler { graphqlTypeNames.remove("Mutation"); graphqlTypeNames.remove("Subscription"); - // Match schema type names to Java classes + // Match schema type names to Java classes (include all FQCN variants) List<String> result = new ArrayList<>(); Set<String> unmatched = new HashSet<>(); for (String typeName : graphqlTypeNames) { - String fqcn = simpleNameIndex.get(typeName); - if (fqcn != null) { - result.add(fqcn); + List<String> fqcns = simpleNameIndex.get(typeName); + if (fqcns != null) { + result.addAll(fqcns); } else { unmatched.add(typeName); }
