Re-add test runtime hints (#13511)

This commit is contained in:
Jean Bisutti 2025-03-13 21:20:10 +01:00 committed by GitHub
parent 287b097fe9
commit 76dc8aa8f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 0 deletions

View File

@ -5,7 +5,9 @@
package io.opentelemetry.spring.smoketest;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.aot.hint.TypeReference;
// Necessary for GraalVM native test
public class RuntimeHints implements RuntimeHintsRegistrar {
@ -14,5 +16,16 @@ public class RuntimeHints implements RuntimeHintsRegistrar {
public void registerHints(
org.springframework.aot.hint.RuntimeHints hints, ClassLoader classLoader) {
hints.resources().registerResourceBundle("org.apache.commons.dbcp2.LocalStrings");
// To avoid Spring native issue with MongoDB: java.lang.ClassNotFoundException:
// org.springframework.data.mongodb.core.aggregation.AggregationOperation
hints
.reflection()
.registerType(
TypeReference.of(
"org.springframework.data.mongodb.core.aggregation.AggregationOperation"),
hint -> {
hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
});
}
}

View File

@ -5,7 +5,9 @@
package io.opentelemetry.spring.smoketest;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.aot.hint.TypeReference;
// Necessary for GraalVM native test
public class RuntimeHints implements RuntimeHintsRegistrar {
@ -14,5 +16,16 @@ public class RuntimeHints implements RuntimeHintsRegistrar {
public void registerHints(
org.springframework.aot.hint.RuntimeHints hints, ClassLoader classLoader) {
hints.resources().registerResourceBundle("org.apache.commons.dbcp2.LocalStrings");
// To avoid Spring native issue with MongoDB: java.lang.ClassNotFoundException:
// org.springframework.data.mongodb.core.aggregation.AggregationOperation
hints
.reflection()
.registerType(
TypeReference.of(
"org.springframework.data.mongodb.core.aggregation.AggregationOperation"),
hint -> {
hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
});
}
}