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 8487ab5b88684de55efc298c729f38d371f407ad..b61cfea07350b857552b3c61a9b5093e6cb5a959 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-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 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 b40e0483f3e1df902bcd8d2a3173e806ba26d5cb..2050bbdf7d6c4587ed34bd905244109d1eb4b192 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 fcda20d4688dd5d4378718216360dd60d1b661a1..7c60bee6675abf3dbe1208d2ff221bd5c9888fa8 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. @@ -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;