This is an automated email from the ASF dual-hosted git repository.
tcunning pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git
The following commit(s) were added to refs/heads/main by this push:
new e5a3c6a065e CAMEL-23265 Fix unchecked/unsafe operations warning in
camel-spring-boot-generator-maven-plugin
e5a3c6a065e is described below
commit e5a3c6a065e767b0ff996280c7704048c057e5bb
Author: Tom Cunningham <[email protected]>
AuthorDate: Fri Mar 27 13:43:37 2026 -0400
CAMEL-23265 Fix unchecked/unsafe operations warning in
camel-spring-boot-generator-maven-plugin
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
---
.../maven/SpringBootAutoConfigurationMojo.java | 24 +++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git
a/tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojo.java
b/tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojo.java
index e0b14818620..9c59316f33f 100644
---
a/tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojo.java
+++
b/tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojo.java
@@ -309,7 +309,7 @@ public class SpringBootAutoConfigurationMojo extends
AbstractSpringBootGenerator
configClass.setPackage(packageName);
configClass.setName(configName);
configClass.extendSuperType(commonClass);
-
configClass.addAnnotation(loadClass("org.springframework.boot.context.properties.ConfigurationProperties"))
+
configClass.addAnnotation(loadAnnotationClass("org.springframework.boot.context.properties.ConfigurationProperties"))
.setStringValue("prefix", propertiesPrefix);
configClass.addImport(Map.class);
configClass.addImport(HashMap.class);
@@ -884,6 +884,28 @@ public class SpringBootAutoConfigurationMojo extends
AbstractSpringBootGenerator
return optionClass;
}
+ // try loading annotation class, looking for inner classes if needed
+ private Class<? extends java.lang.annotation.Annotation>
loadAnnotationClass(String loadClassName) throws MojoFailureException {
+ String currentClassName = loadClassName;
+ ClassNotFoundException lastException = null;
+
+ while (currentClassName != null) {
+ try {
+ return
getProjectClassLoader().loadClass(currentClassName).asSubclass(java.lang.annotation.Annotation.class);
+ } catch (ClassNotFoundException e) {
+ lastException = e;
+ int dotIndex = currentClassName.lastIndexOf('.');
+ if (dotIndex == -1) {
+ currentClassName = null;
+ } else {
+ currentClassName = currentClassName.substring(0, dotIndex)
+ "$" + currentClassName.substring(dotIndex + 1);
+ }
+ }
+ }
+
+ throw new MojoFailureException(lastException.getMessage(),
lastException);
+ }
+
protected DynamicClassLoader getProjectClassLoader() {
if (projectClassLoader == null) {
final List<String> classpathElements;