Don't throw NPE when serving webjar directories

Prior to this change, serving resources with ResourceHttpRequestHandler
could result in NPE when requesting an existing folder located in a JAR.

This commit swallows those exceptions, as it is not possible to foresee
those cases without reading the actual resource. This result in a HTTP
200 response with a zero Content-Length instead of a HTTP 500 internal
exception.

Issue: SPR-13620
This commit is contained in:
Brian Clozel
2015-10-29 16:10:27 +01:00
parent 323fa8510d
commit 9334fabe26
2 changed files with 17 additions and 0 deletions

View File

@@ -460,6 +460,9 @@ public class ResourceHttpRequestHandler extends WebContentGenerator
try {
StreamUtils.copy(in, response.getOutputStream());
}
catch (NullPointerException ex) {
// ignore, see SPR-13620
}
finally {
try {
in.close();