diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedMethod.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedMethod.java index e50e79bf90..fd8fb10799 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedMethod.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedMethod.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -214,8 +214,8 @@ public class AnnotatedMethod { @Override public boolean equals(@Nullable Object other) { - return (this == other || (other != null && getClass() == other.getClass() && - this.method.equals(((AnnotatedMethod) other).method))); + return (this == other || (other instanceof AnnotatedMethod otherHandlerMethod && + this.method.equals(otherHandlerMethod.method))); } @Override