Be more defensive about exceptions from resource

Otherwise you can get an exception here that is unuseful, e.g. from
a ServletContext that isn't properly initialized.
This commit is contained in:
Dave Syer 2015-10-29 08:41:00 +00:00
parent abd7bc0466
commit ae0eed5bf5
1 changed files with 5 additions and 6 deletions

View File

@ -16,7 +16,6 @@
package org.springframework.boot.autoconfigure.web;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -92,14 +91,14 @@ public class ResourceProperties implements ResourceLoaderAware {
public Resource getWelcomePage() {
for (String location : getStaticWelcomePageLocations()) {
Resource resource = this.resourceLoader.getResource(location);
if (resource.exists()) {
try {
try {
if (resource.exists()) {
resource.getURL();
return resource;
}
catch (IOException ex) {
// Ignore
}
}
catch (Exception ex) {
// Ignore
}
}
return null;