Polish WebJarsResourceResolver

Fix a potential NPE when trying to resolve non-existing webjars
resources in the resolver chain.
This commit is contained in:
Brian Clozel 2015-07-27 14:16:09 +02:00
parent 40ea9ffd63
commit accb8519fd
2 changed files with 4 additions and 1 deletions

View File

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

View File

@ -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