gnodet-bot commented on code in PR #29225:
URL: https://github.com/apache/camel/pull/29225#discussion_r4479123945


##########
components/camel-debezium/camel-debezium-common/camel-debezium-maven-plugin/src/main/java/org/apache/camel/maven/config/ConnectorConfigGenerator.java:
##########
@@ -155,6 +176,19 @@ public String toString() {
         return printClassAsString();
     }
 
+    private static Field getConfigClassField(final Class<?> configClass, final 
String name) {
+        try {
+            if (configClass.getField(name).get(null) instanceof Field field) {

Review Comment:
   ⚠️ **`NullPointerException` escapes the catch block**
   
   `Field.get(null)` throws `NullPointerException` when the field is not 
`static`. `NullPointerException` is not a subclass of 
`ReflectiveOperationException`, so the existing `catch` block will NOT catch it 
— the NPE propagates unchecked with no actionable message.
   
   While Debezium config classes conventionally use `public static Field`, 
`Class.getField()` accepts any public field, and there is no 
`Modifier.isStatic()` guard here. Consider:
   
   ```suggestion
               Field f = configClass.getField(name);
               if (!java.lang.reflect.Modifier.isStatic(f.getModifiers())) {
                   throw new IllegalArgumentException(
                           String.format("Field '%s' of class '%s' is not 
static", name, configClass.getName()));
               }
               if (f.get(null) instanceof Field field) {
   ```
   
   Or at minimum widen the catch to also include `NullPointerException`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to