Handle AccessControlException in JspTemplateAvailabilityProvider

See gh-15778
pull/15889/head
ayudovin 6 years ago committed by Stephane Nicoll
parent 66f60fbb7a
commit 81273bdf9a

@ -17,6 +17,7 @@
package org.springframework.boot.autoconfigure.web.servlet; package org.springframework.boot.autoconfigure.web.servlet;
import java.io.File; import java.io.File;
import java.security.AccessControlException;
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider; import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
@ -30,6 +31,7 @@ import org.springframework.util.ClassUtils;
* @author Andy Wilkinson * @author Andy Wilkinson
* @author Stephane Nicoll * @author Stephane Nicoll
* @author Madhura Bhave * @author Madhura Bhave
* @author Artsiom Yudovin
* @since 1.1.0 * @since 1.1.0
*/ */
public class JspTemplateAvailabilityProvider implements TemplateAvailabilityProvider { public class JspTemplateAvailabilityProvider implements TemplateAvailabilityProvider {
@ -38,11 +40,17 @@ public class JspTemplateAvailabilityProvider implements TemplateAvailabilityProv
public boolean isTemplateAvailable(String view, Environment environment, public boolean isTemplateAvailable(String view, Environment environment,
ClassLoader classLoader, ResourceLoader resourceLoader) { ClassLoader classLoader, ResourceLoader resourceLoader) {
if (ClassUtils.isPresent("org.apache.jasper.compiler.JspConfig", classLoader)) { if (ClassUtils.isPresent("org.apache.jasper.compiler.JspConfig", classLoader)) {
String resourceName = getResourceName(view, environment); String resourceName = getResourceName(view, environment);
if (resourceLoader.getResource(resourceName).exists()) { if (resourceLoader.getResource(resourceName).exists()) {
return true; return true;
} }
return new File("src/main/webapp", resourceName).exists();
try {
return new File("src/main/webapp", resourceName).exists();
}
catch (AccessControlException ex) {
}
} }
return false; return false;
} }

Loading…
Cancel
Save