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

markt-asf pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
     new 24083f1238 Review "Fix covariant return type overrides of annotated 
POJO ..."
24083f1238 is described below

commit 24083f1238e675c2b2981c1c889a55ade2c903f6
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Nov 5 10:07:13 2026 +0000

    Review "Fix covariant return type overrides of annotated POJO ..."
    
    Simplify
    
    Co-authored by: Claude / Sonnet 5.5
---
 java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java 
b/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java
index 93176ec939..ec1de64b66 100644
--- a/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java
+++ b/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java
@@ -204,14 +204,12 @@ public class PojoMethodMapping {
 
 
     private boolean isMethodOverride(Method method1, Method method2) {
-        // An overriding method may use a covariant return type so the return
-        // types do not have to be equal. They do need to be compatible. The
-        // methods may be passed in either order so both directions are
-        // checked.
-        Class<?> returnType1 = method1.getReturnType();
-        Class<?> returnType2 = method2.getReturnType();
+        // The return type is deliberately not compared. An overriding method 
may
+        // use a covariant return type and, within a single class hierarchy, 
two
+        // methods with the same name and parameter types are override
+        // equivalent since the compiler does not permit them to differ only in
+        // return type unless one overrides the other.
         return method1.getName().equals(method2.getName()) &&
-                (returnType1.isAssignableFrom(returnType2) || 
returnType2.isAssignableFrom(returnType1)) &&
                 Arrays.equals(method1.getParameterTypes(), 
method2.getParameterTypes());
     }
 


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

Reply via email to