Consistent use of @Nullable in spring-test

This commit also removes nullability from two common spots: ResolvableType.getType() and TargetSource.getTarget(), both of which are never effectively null with any regular implementation. For such scenarios, a non-null empty type/target is the cleaner contract.

Issue: SPR-15540
This commit is contained in:
Juergen Hoeller
2017-06-08 22:52:57 +02:00
parent ee5fa2633a
commit fd53d2a51a
134 changed files with 812 additions and 777 deletions

View File

@@ -111,7 +111,7 @@ public final class MappedInterceptor implements HandlerInterceptor {
}
/**
* The configured PathMatcher, or {@code null}.
* The configured PathMatcher, or {@code null} if none.
*/
@Nullable
public PathMatcher getPathMatcher() {
@@ -121,6 +121,7 @@ public final class MappedInterceptor implements HandlerInterceptor {
/**
* The path into the application the interceptor is mapped to.
*/
@Nullable
public String[] getPathPatterns() {
return this.includePatterns;
}

View File

@@ -278,7 +278,6 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
* Return the generic type of the {@code returnType} (or of the nested type
* if it is an {@link HttpEntity}).
*/
@Nullable
private Type getGenericType(MethodParameter returnType) {
if (HttpEntity.class.isAssignableFrom(returnType.getParameterType())) {
return ResolvableType.forType(returnType.getGenericParameterType()).getGeneric().getType();

View File

@@ -519,11 +519,12 @@ public class UrlBasedViewResolver extends AbstractCachingViewResolver implements
private View applyLifecycleMethods(String viewName, AbstractView view) {
ApplicationContext context = getApplicationContext();
if (context != null) {
return (View) context.getAutowireCapableBeanFactory().initializeBean(view, viewName);
}
else {
return view;
Object initialized = context.getAutowireCapableBeanFactory().initializeBean(view, viewName);
if (initialized instanceof View) {
return (View) initialized;
}
}
return view;
}
/**