Skip to content

Commit 6825287

Browse files
committed
Polishing
1 parent 737d77a commit 6825287

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

spring-web/src/main/java/org/springframework/web/method/annotation/MapMethodProcessor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -42,8 +42,8 @@ public class MapMethodProcessor implements HandlerMethodArgumentResolver, Handle
4242

4343
@Override
4444
public boolean supportsParameter(MethodParameter parameter) {
45-
return Map.class.isAssignableFrom(parameter.getParameterType()) &&
46-
parameter.getParameterAnnotations().length == 0;
45+
return (Map.class.isAssignableFrom(parameter.getParameterType()) &&
46+
parameter.getParameterAnnotations().length == 0);
4747
}
4848

4949
@Override
@@ -70,8 +70,8 @@ public void handleReturnValue(@Nullable Object returnValue, MethodParameter retu
7070
}
7171
else if (returnValue != null) {
7272
// should not happen
73-
throw new UnsupportedOperationException("Unexpected return type: " +
74-
returnType.getParameterType().getName() + " in method: " + returnType.getMethod());
73+
throw new UnsupportedOperationException("Unexpected return type [" +
74+
returnType.getParameterType().getName() + "] in method: " + returnType.getMethod());
7575
}
7676
}
7777

spring-web/src/main/java/org/springframework/web/method/annotation/ModelMethodProcessor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -70,8 +70,8 @@ else if (returnValue instanceof Model) {
7070
}
7171
else {
7272
// should not happen
73-
throw new UnsupportedOperationException("Unexpected return type: " +
74-
returnType.getParameterType().getName() + " in method: " + returnType.getMethod());
73+
throw new UnsupportedOperationException("Unexpected return type [" +
74+
returnType.getParameterType().getName() + "] in method: " + returnType.getMethod());
7575
}
7676
}
7777

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/PrincipalMethodArgumentResolver.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,24 @@
3838
*/
3939
public class PrincipalMethodArgumentResolver implements HandlerMethodArgumentResolver {
4040

41-
4241
@Override
4342
public boolean supportsParameter(MethodParameter parameter) {
44-
Class<?> paramType = parameter.getParameterType();
45-
return Principal.class.isAssignableFrom(paramType);
43+
return Principal.class.isAssignableFrom(parameter.getParameterType());
4644
}
4745

4846
@Override
4947
public Object resolveArgument(MethodParameter parameter, @Nullable ModelAndViewContainer mavContainer,
5048
NativeWebRequest webRequest, @Nullable WebDataBinderFactory binderFactory) throws Exception {
5149

52-
Class<?> paramType = parameter.getParameterType();
53-
5450
HttpServletRequest request = webRequest.getNativeRequest(HttpServletRequest.class);
5551
if (request == null) {
56-
throw new IllegalStateException(
57-
"Current request is not of type [HttpServletRequest]: " + webRequest);
52+
throw new IllegalStateException("Current request is not of type HttpServletRequest: " + webRequest);
5853
}
5954

6055
Principal principal = request.getUserPrincipal();
61-
if (principal != null && !paramType.isInstance(principal)) {
62-
throw new IllegalStateException(
63-
"Current user principal is not of type [" + paramType.getName() + "]: " + principal);
56+
if (principal != null && !parameter.getParameterType().isInstance(principal)) {
57+
throw new IllegalStateException("Current user principal is not of type [" +
58+
parameter.getParameterType().getName() + "]: " + principal);
6459
}
6560

6661
return principal;

0 commit comments

Comments
 (0)