diff --git a/spring-web/src/main/java/org/springframework/http/MediaTypeFactory.java b/spring-web/src/main/java/org/springframework/http/MediaTypeFactory.java index 7ad0969f2b..cd289460f8 100644 --- a/spring-web/src/main/java/org/springframework/http/MediaTypeFactory.java +++ b/spring-web/src/main/java/org/springframework/http/MediaTypeFactory.java @@ -1,5 +1,5 @@ /* - * 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"); * 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 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 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); } } diff --git a/spring-web/src/main/java/org/springframework/web/method/HandlerTypePredicate.java b/spring-web/src/main/java/org/springframework/web/method/HandlerTypePredicate.java index b40e0483f3..2050bbdf7d 100644 --- a/spring-web/src/main/java/org/springframework/web/method/HandlerTypePredicate.java +++ b/spring-web/src/main/java/org/springframework/web/method/HandlerTypePredicate.java @@ -1,5 +1,5 @@ /* - * 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> { @Override - public boolean test(Class controllerType) { + public boolean test(@Nullable Class controllerType) { if (!hasSelectors()) { return true; } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java index 765823866b..a437295c92 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java @@ -1,5 +1,5 @@ /* - * 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. @@ -718,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) { if (method.getName().equals("getControllerType")) { return this.controllerType; }