From 19779951a12b4a8f6139f3b3339ef8ea45a9af4c Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 24 Sep 2018 10:23:59 +0200 Subject: [PATCH] Handle class not found See gh-14575 --- .../env/DevToolsPropertyDefaultsPostProcessor.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsPropertyDefaultsPostProcessor.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsPropertyDefaultsPostProcessor.java index 3caad59481..f7c3463110 100755 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsPropertyDefaultsPostProcessor.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsPropertyDefaultsPostProcessor.java @@ -121,7 +121,7 @@ public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostPro private boolean isWebApplication(Environment environment) { for (String candidate : WEB_ENVIRONMENT_CLASSES) { - Class environmentClass = ClassUtils.resolveClassName(candidate, + Class environmentClass = resolveClassName(candidate, environment.getClass().getClassLoader()); if (environmentClass != null && environmentClass.isInstance(environment)) { return true; @@ -130,4 +130,13 @@ public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostPro return false; } + private Class resolveClassName(String candidate, ClassLoader classLoader) { + try { + return ClassUtils.resolveClassName(candidate, classLoader); + } + catch (IllegalArgumentException ex) { + return null; + } + } + }