From 5b9129724baff35fe50725e23bce79a3573eefa6 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 31 Jul 2019 23:34:41 +0200 Subject: [PATCH] Polishing --- .../beans/factory/config/DependencyDescriptor.java | 9 ++++++--- .../HandlerMethodArgumentResolverComposite.java | 7 +++---- .../java/org/springframework/http/HttpStatus.java | 7 ++++++- .../HandlerMethodArgumentResolverComposite.java | 13 ++++++------- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java index a10bbe46ee2..8c52bf393bc 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -84,8 +84,9 @@ public class DependencyDescriptor extends InjectionPoint implements Serializable */ public DependencyDescriptor(MethodParameter methodParameter, boolean required, boolean eager) { super(methodParameter); + this.declaringClass = methodParameter.getDeclaringClass(); - if (this.methodParameter.getMethod() != null) { + if (methodParameter.getMethod() != null) { this.methodName = methodParameter.getMethod().getName(); this.parameterTypes = methodParameter.getMethod().getParameterTypes(); } @@ -117,6 +118,7 @@ public class DependencyDescriptor extends InjectionPoint implements Serializable */ public DependencyDescriptor(Field field, boolean required, boolean eager) { super(field); + this.declaringClass = field.getDeclaringClass(); this.fieldName = field.getName(); this.required = required; @@ -129,6 +131,7 @@ public class DependencyDescriptor extends InjectionPoint implements Serializable */ public DependencyDescriptor(DependencyDescriptor original) { super(original); + this.declaringClass = original.declaringClass; this.methodName = original.methodName; this.parameterTypes = original.parameterTypes; @@ -236,7 +239,7 @@ public class DependencyDescriptor extends InjectionPoint implements Serializable } /** - * Build a ResolvableType object for the wrapped parameter/field. + * Build a {@link ResolvableType} object for the wrapped parameter/field. * @since 4.0 */ public ResolvableType getResolvableType() { diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/HandlerMethodArgumentResolverComposite.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/HandlerMethodArgumentResolverComposite.java index 56f5efd2f24..07478bd1731 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/HandlerMethodArgumentResolverComposite.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/HandlerMethodArgumentResolverComposite.java @@ -45,8 +45,8 @@ public class HandlerMethodArgumentResolverComposite implements HandlerMethodArgu /** * Add the given {@link HandlerMethodArgumentResolver}. */ - public HandlerMethodArgumentResolverComposite addResolver(HandlerMethodArgumentResolver argumentResolver) { - this.argumentResolvers.add(argumentResolver); + public HandlerMethodArgumentResolverComposite addResolver(HandlerMethodArgumentResolver resolver) { + this.argumentResolvers.add(resolver); return this; } @@ -99,8 +99,7 @@ public class HandlerMethodArgumentResolverComposite implements HandlerMethodArgu * Iterate over registered * {@link HandlerMethodArgumentResolver HandlerMethodArgumentResolvers} * and invoke the one that supports it. - * @throws IllegalStateException if no suitable - * {@link HandlerMethodArgumentResolver} is found. + * @throws IllegalArgumentException if no suitable argument resolver is found */ @Override public Object resolveArgument(MethodParameter parameter, Message message) throws Exception { diff --git a/spring-web/src/main/java/org/springframework/http/HttpStatus.java b/spring-web/src/main/java/org/springframework/http/HttpStatus.java index e74a33e5be5..5d79135d351 100644 --- a/spring-web/src/main/java/org/springframework/http/HttpStatus.java +++ b/spring-web/src/main/java/org/springframework/http/HttpStatus.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -431,6 +431,7 @@ public enum HttpStatus { * Whether this status code is in the HTTP series * {@link org.springframework.http.HttpStatus.Series#INFORMATIONAL}. * This is a shortcut for checking the value of {@link #series()}. + * @since 4.0 * @see #series() */ public boolean is1xxInformational() { @@ -441,6 +442,7 @@ public enum HttpStatus { * Whether this status code is in the HTTP series * {@link org.springframework.http.HttpStatus.Series#SUCCESSFUL}. * This is a shortcut for checking the value of {@link #series()}. + * @since 4.0 * @see #series() */ public boolean is2xxSuccessful() { @@ -451,6 +453,7 @@ public enum HttpStatus { * Whether this status code is in the HTTP series * {@link org.springframework.http.HttpStatus.Series#REDIRECTION}. * This is a shortcut for checking the value of {@link #series()}. + * @since 4.0 * @see #series() */ public boolean is3xxRedirection() { @@ -461,6 +464,7 @@ public enum HttpStatus { * Whether this status code is in the HTTP series * {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR}. * This is a shortcut for checking the value of {@link #series()}. + * @since 4.0 * @see #series() */ public boolean is4xxClientError() { @@ -471,6 +475,7 @@ public enum HttpStatus { * Whether this status code is in the HTTP series * {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR}. * This is a shortcut for checking the value of {@link #series()}. + * @since 4.0 * @see #series() */ public boolean is5xxServerError() { diff --git a/spring-web/src/main/java/org/springframework/web/method/support/HandlerMethodArgumentResolverComposite.java b/spring-web/src/main/java/org/springframework/web/method/support/HandlerMethodArgumentResolverComposite.java index fa30ef76da0..763933bc095 100644 --- a/spring-web/src/main/java/org/springframework/web/method/support/HandlerMethodArgumentResolverComposite.java +++ b/spring-web/src/main/java/org/springframework/web/method/support/HandlerMethodArgumentResolverComposite.java @@ -106,10 +106,9 @@ public class HandlerMethodArgumentResolverComposite implements HandlerMethodArgu /** * Iterate over registered - * {@link HandlerMethodArgumentResolver HandlerMethodArgumentResolvers} and - * invoke the one that supports it. - * @throws IllegalStateException if no suitable - * {@link HandlerMethodArgumentResolver} is found. + * {@link HandlerMethodArgumentResolver HandlerMethodArgumentResolvers} + * and invoke the one that supports it. + * @throws IllegalArgumentException if no suitable argument resolver is found */ @Override public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, @@ -130,9 +129,9 @@ public class HandlerMethodArgumentResolverComposite implements HandlerMethodArgu private HandlerMethodArgumentResolver getArgumentResolver(MethodParameter parameter) { HandlerMethodArgumentResolver result = this.argumentResolverCache.get(parameter); if (result == null) { - for (HandlerMethodArgumentResolver methodArgumentResolver : this.argumentResolvers) { - if (methodArgumentResolver.supportsParameter(parameter)) { - result = methodArgumentResolver; + for (HandlerMethodArgumentResolver resolver : this.argumentResolvers) { + if (resolver.supportsParameter(parameter)) { + result = resolver; this.argumentResolverCache.put(parameter, result); break; }