Skip to content

Commit 19474e2

Browse files
committed
Nullability refinements
(cherry picked from commit f31933e)
1 parent 4307110 commit 19474e2

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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.
@@ -718,7 +718,7 @@ private static class ControllerMethodInvocationInterceptor
718718

719719
@Override
720720
@Nullable
721-
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) {
722722
if (method.getName().equals("getControllerType")) {
723723
return this.controllerType;
724724
}

0 commit comments

Comments
 (0)