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