提交 19474e2d 编写于 作者: J Juergen Hoeller

Nullability refinements

(cherry picked from commit f31933e6)
上级 43071109
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -28,6 +28,7 @@ import java.util.Optional; ...@@ -28,6 +28,7 @@ import java.util.Optional;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -65,6 +66,7 @@ public final class MediaTypeFactory { ...@@ -65,6 +66,7 @@ public final class MediaTypeFactory {
*/ */
private static MultiValueMap<String, MediaType> parseMimeTypes() { private static MultiValueMap<String, MediaType> parseMimeTypes() {
InputStream is = MediaTypeFactory.class.getResourceAsStream(MIME_TYPES_FILE_NAME); 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))) { try (BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.US_ASCII))) {
MultiValueMap<String, MediaType> result = new LinkedMultiValueMap<>(); MultiValueMap<String, MediaType> result = new LinkedMultiValueMap<>();
String line; String line;
...@@ -82,7 +84,7 @@ public final class MediaTypeFactory { ...@@ -82,7 +84,7 @@ public final class MediaTypeFactory {
return result; return result;
} }
catch (IOException ex) { 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -26,6 +26,7 @@ import java.util.Set; ...@@ -26,6 +26,7 @@ import java.util.Set;
import java.util.function.Predicate; import java.util.function.Predicate;
import org.springframework.core.annotation.AnnotationUtils; import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -69,7 +70,7 @@ public final class HandlerTypePredicate implements Predicate<Class<?>> { ...@@ -69,7 +70,7 @@ public final class HandlerTypePredicate implements Predicate<Class<?>> {
@Override @Override
public boolean test(Class<?> controllerType) { public boolean test(@Nullable Class<?> controllerType) {
if (!hasSelectors()) { if (!hasSelectors()) {
return true; 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -718,7 +718,7 @@ public class MvcUriComponentsBuilder { ...@@ -718,7 +718,7 @@ public class MvcUriComponentsBuilder {
@Override @Override
@Nullable @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) {
if (method.getName().equals("getControllerType")) { if (method.getName().equals("getControllerType")) {
return this.controllerType; return this.controllerType;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册