Skip to content

Commit f31933e

Browse files
committed
Nullability refinements
1 parent c7989c7 commit f31933e

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

spring-web/src/main/java/org/springframework/http/MediaTypeFactory.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2021 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.
@@ -28,6 +28,7 @@
2828

2929
import org.springframework.core.io.Resource;
3030
import org.springframework.lang.Nullable;
31+
import org.springframework.util.Assert;
3132
import org.springframework.util.LinkedMultiValueMap;
3233
import org.springframework.util.MultiValueMap;
3334
import org.springframework.util.StringUtils;
@@ -65,6 +66,7 @@ private MediaTypeFactory() {
6566
*/
6667
private static MultiValueMap<String, MediaType> parseMimeTypes() {
6768
InputStream is = MediaTypeFactory.class.getResourceAsStream(MIME_TYPES_FILE_NAME);
69+
Assert.state(is != null, MIME_TYPES_FILE_NAME + " not found in classpath");
6870
try (BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.US_ASCII))) {
6971
MultiValueMap<String, MediaType> result = new LinkedMultiValueMap<>();
7072
String line;
@@ -82,7 +84,7 @@ private static MultiValueMap<String, MediaType> parseMimeTypes() {
8284
return result;
8385
}
8486
catch (IOException ex) {
85-
throw new IllegalStateException("Could not load '" + MIME_TYPES_FILE_NAME + "'", ex);
87+
throw new IllegalStateException("Could not read " + MIME_TYPES_FILE_NAME, ex);
8688
}
8789
}
8890

spring-web/src/main/java/org/springframework/web/method/HandlerTypePredicate.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2021 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.
@@ -26,6 +26,7 @@
2626
import java.util.function.Predicate;
2727

2828
import org.springframework.core.annotation.AnnotationUtils;
29+
import org.springframework.lang.Nullable;
2930
import org.springframework.util.ClassUtils;
3031
import org.springframework.util.StringUtils;
3132

@@ -69,7 +70,7 @@ private HandlerTypePredicate(Set<String> basePackages, List<Class<?>> assignable
6970

7071

7172
@Override
72-
public boolean test(Class<?> controllerType) {
73+
public boolean test(@Nullable Class<?> controllerType) {
7374
if (!hasSelectors()) {
7475
return true;
7576
}

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2021 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.
@@ -97,7 +97,9 @@
9797
*/
9898
public class MvcUriComponentsBuilder {
9999

100-
/** Well-known name for the {@link CompositeUriComponentsContributor} object in the bean factory. */
100+
/**
101+
* Well-known name for the {@link CompositeUriComponentsContributor} object in the bean factory.
102+
*/
101103
public static final String MVC_URI_COMPONENTS_CONTRIBUTOR_BEAN_NAME = "mvcUriComponentsContributor";
102104

103105

@@ -716,7 +718,7 @@ private static class ControllerMethodInvocationInterceptor
716718

717719
@Override
718720
@Nullable
719-
public Object intercept(Object obj, Method method, Object[] args, @Nullable MethodProxy proxy) {
721+
public Object intercept(@Nullable Object obj, Method method, Object[] args, @Nullable MethodProxy proxy) {
720722
switch (method.getName()) {
721723
case "getControllerType": return this.controllerType;
722724
case "getControllerMethod": return this.controllerMethod;

0 commit comments

Comments
 (0)