This is an automated email from the ASF dual-hosted git repository.

rmaucher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit cdd3a803d675bf35f5cfc0e431834ce661557dad
Author: opencode <[email protected]>
AuthorDate: Wed Sep 30 13:43:51 2026 +0200

    Walk the class hierarchy in NamingResourcesImpl getSetterType() and 
getFieldType() so that injection targets resolving to inherited fields or 
setters are no longer rejected at deployment, matching the behaviour of the 
runtime injection engine
---
 .../apache/catalina/deploy/NamingResourcesImpl.java   | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/catalina/deploy/NamingResourcesImpl.java 
b/java/org/apache/catalina/deploy/NamingResourcesImpl.java
index bed94cff45..6e0612871a 100644
--- a/java/org/apache/catalina/deploy/NamingResourcesImpl.java
+++ b/java/org/apache/catalina/deploy/NamingResourcesImpl.java
@@ -1184,18 +1184,25 @@ public class NamingResourcesImpl extends 
LifecycleMBeanBase implements Serializa
     }
 
     private Class<?> getSetterType(Class<?> clazz, String name) {
-        for (Method method : clazz.getDeclaredMethods()) {
-            if (Introspection.isValidSetter(method) && 
Introspection.getPropertyName(method).equals(name)) {
-                return method.getParameterTypes()[0];
+        // The runtime injection engine (DefaultInstanceManager) matches
+        // injection targets across the whole class hierarchy, so the checks
+        // here must do the same
+        for (Class<?> c = clazz; c != null; c = c.getSuperclass()) {
+            for (Method method : c.getDeclaredMethods()) {
+                if (Introspection.isValidSetter(method) && 
Introspection.getPropertyName(method).equals(name)) {
+                    return method.getParameterTypes()[0];
+                }
             }
         }
         return null;
     }
 
     private Class<?> getFieldType(Class<?> clazz, String name) {
-        for (Field field : clazz.getDeclaredFields()) {
-            if (field.getName().equals(name)) {
-                return field.getType();
+        for (Class<?> c = clazz; c != null; c = c.getSuperclass()) {
+            for (Field field : c.getDeclaredFields()) {
+                if (field.getName().equals(name)) {
+                    return field.getType();
+                }
             }
         }
         return null;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to