Handle class not found

See gh-14575
pull/14592/head
Stephane Nicoll 6 years ago
parent 0f11e69ca3
commit 19779951a1

@ -121,7 +121,7 @@ public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostPro
private boolean isWebApplication(Environment environment) { private boolean isWebApplication(Environment environment) {
for (String candidate : WEB_ENVIRONMENT_CLASSES) { for (String candidate : WEB_ENVIRONMENT_CLASSES) {
Class<?> environmentClass = ClassUtils.resolveClassName(candidate, Class<?> environmentClass = resolveClassName(candidate,
environment.getClass().getClassLoader()); environment.getClass().getClassLoader());
if (environmentClass != null && environmentClass.isInstance(environment)) { if (environmentClass != null && environmentClass.isInstance(environment)) {
return true; return true;
@ -130,4 +130,13 @@ public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostPro
return false; return false;
} }
private Class<?> resolveClassName(String candidate, ClassLoader classLoader) {
try {
return ClassUtils.resolveClassName(candidate, classLoader);
}
catch (IllegalArgumentException ex) {
return null;
}
}
} }

Loading…
Cancel
Save