Skip to content

Commit b9786cc

Browse files
committed
Fix minor issue in HandlerMethod
Before this change HandlerMethod used ClassUtils.getUserClass(Class<?>) to get the real user class, and not one generated by CGlib. However it failed to that under all circumstances. This change fixes that. Issue: SPR-9490
1 parent a4240d2 commit b9786cc

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

spring-web/src/main/java/org/springframework/web/method/HandlerMethod.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,21 +124,18 @@ public Method getMethod() {
124124
* Note that if the bean type is a CGLIB-generated class, the original, user-defined class is returned.
125125
*/
126126
public Class<?> getBeanType() {
127-
if (bean instanceof String) {
128-
String beanName = (String) bean;
129-
return beanFactory.getType(beanName);
130-
}
131-
else {
132-
return ClassUtils.getUserClass(bean.getClass());
133-
}
127+
Class<?> clazz = (this.bean instanceof String)
128+
? this.beanFactory.getType((String) this.bean) : this.bean.getClass();
129+
130+
return ClassUtils.getUserClass(clazz);
134131
}
135132

136133
/**
137134
* If the bean method is a bridge method, this method returns the bridged (user-defined) method.
138135
* Otherwise it returns the same method as {@link #getMethod()}.
139136
*/
140137
protected Method getBridgedMethod() {
141-
return bridgedMethod;
138+
return this.bridgedMethod;
142139
}
143140

144141
/**
@@ -153,7 +150,7 @@ public MethodParameter[] getMethodParameters() {
153150
}
154151
this.parameters = p;
155152
}
156-
return parameters;
153+
return this.parameters;
157154
}
158155

159156
/**
@@ -197,7 +194,7 @@ public HandlerMethod createWithResolvedBean() {
197194
String beanName = (String) this.bean;
198195
handler = this.beanFactory.getBean(beanName);
199196
}
200-
return new HandlerMethod(handler, method);
197+
return new HandlerMethod(handler, this.method);
201198
}
202199

203200
@Override

0 commit comments

Comments
 (0)