Polish WebJarsResourceResolver

Fix a potential NPE when trying to resolve non-existing webjars
resources in the resolver chain.
master
Brian Clozel 9 years ago
parent 40ea9ffd63
commit accb8519fd
  1. 2
      spring-webmvc/src/main/java/org/springframework/web/servlet/resource/WebJarsResourceResolver.java
  2. 1
      spring-webmvc/src/test/java/org/springframework/web/servlet/resource/WebJarsResourceResolverTests.java

@ -75,8 +75,10 @@ public class WebJarsResourceResolver extends AbstractResourceResolver {
String path = chain.resolveUrlPath(resourceUrlPath, locations);
if (path == null) {
String webJarResourcePath = findWebJarResourcePath(resourceUrlPath);
if(webJarResourcePath != null) {
return chain.resolveUrlPath(webJarResourcePath, locations);
}
}
return path;
}

@ -107,6 +107,7 @@ public class WebJarsResourceResolverTests {
assertNull(actual);
verify(this.chain, times(1)).resolveUrlPath(file, this.locations);
verify(this.chain, never()).resolveUrlPath(null, this.locations);
}
@Test

Loading…
Cancel
Save