Commit 12045598 authored by Phillip Webb's avatar Phillip Webb

Refine agent reloader detection

Fixes gh-4366
parent 6ae02196
...@@ -16,6 +16,10 @@ ...@@ -16,6 +16,10 @@
package org.springframework.boot.devtools.restart; package org.springframework.boot.devtools.restart;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
/** /**
...@@ -26,6 +30,15 @@ import org.springframework.util.ClassUtils; ...@@ -26,6 +30,15 @@ import org.springframework.util.ClassUtils;
*/ */
public abstract class AgentReloader { public abstract class AgentReloader {
private static final Set<String> AGENT_CLASSES;
static {
Set<String> agentClasses = new LinkedHashSet<String>();
agentClasses.add("org.zeroturnaround.javarebel.Integration");
agentClasses.add("org.zeroturnaround.javarebel.ReloaderFactory");
AGENT_CLASSES = Collections.unmodifiableSet(agentClasses);
}
private AgentReloader() { private AgentReloader() {
} }
...@@ -34,15 +47,17 @@ public abstract class AgentReloader { ...@@ -34,15 +47,17 @@ public abstract class AgentReloader {
* @return true if agent reloading is active * @return true if agent reloading is active
*/ */
public static boolean isActive() { public static boolean isActive() {
return isJRebelActive(); return isActive(null) || isActive(AgentReloader.class.getClassLoader())
|| isActive(ClassLoader.getSystemClassLoader());
} }
/** private static boolean isActive(ClassLoader classLoader) {
* Determine if JRebel is active. for (String agentClass : AGENT_CLASSES) {
* @return true if JRebel is active if (ClassUtils.isPresent(agentClass, classLoader)) {
*/ return true;
public static boolean isJRebelActive() { }
return ClassUtils.isPresent("org.zeroturnaround.javarebel.ReloaderFactory", null); }
return false;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment