提交 f31933e6 编写于 作者: J Juergen Hoeller

Nullability refinements

上级 c7989c78
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 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.
......@@ -28,6 +28,7 @@ import java.util.Optional;
import org.springframework.core.io.Resource;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
......@@ -65,6 +66,7 @@ public final class MediaTypeFactory {
*/
private static MultiValueMap<String, MediaType> parseMimeTypes() {
InputStream is = MediaTypeFactory.class.getResourceAsStream(MIME_TYPES_FILE_NAME);
Assert.state(is != null, MIME_TYPES_FILE_NAME + " not found in classpath");
try (BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.US_ASCII))) {
MultiValueMap<String, MediaType> result = new LinkedMultiValueMap<>();
String line;
......@@ -82,7 +84,7 @@ public final class MediaTypeFactory {
return result;
}
catch (IOException ex) {
throw new IllegalStateException("Could not load '" + MIME_TYPES_FILE_NAME + "'", ex);
throw new IllegalStateException("Could not read " + MIME_TYPES_FILE_NAME, ex);
}
}
......
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2021 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.
......@@ -26,6 +26,7 @@ import java.util.Set;
import java.util.function.Predicate;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
......@@ -69,7 +70,7 @@ public final class HandlerTypePredicate implements Predicate<Class<?>> {
@Override
public boolean test(Class<?> controllerType) {
public boolean test(@Nullable Class<?> controllerType) {
if (!hasSelectors()) {
return true;
}
......
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 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.
......@@ -97,7 +97,9 @@ import org.springframework.web.util.UriComponentsBuilder;
*/
public class MvcUriComponentsBuilder {
/** Well-known name for the {@link CompositeUriComponentsContributor} object in the bean factory. */
/**
* Well-known name for the {@link CompositeUriComponentsContributor} object in the bean factory.
*/
public static final String MVC_URI_COMPONENTS_CONTRIBUTOR_BEAN_NAME = "mvcUriComponentsContributor";
......@@ -716,7 +718,7 @@ public class MvcUriComponentsBuilder {
@Override
@Nullable
public Object intercept(Object obj, Method method, Object[] args, @Nullable MethodProxy proxy) {
public Object intercept(@Nullable Object obj, Method method, Object[] args, @Nullable MethodProxy proxy) {
switch (method.getName()) {
case "getControllerType": return this.controllerType;
case "getControllerMethod": return this.controllerMethod;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册