Skip to content

Commit 1204559

Browse files
committed
Refine agent reloader detection
Fixes gh-4366
1 parent 6ae0219 commit 1204559

File tree

1 file changed

+22
-7
lines changed
  • spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart

1 file changed

+22
-7
lines changed

spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/AgentReloader.java

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616

1717
package org.springframework.boot.devtools.restart;
1818

19+
import java.util.Collections;
20+
import java.util.LinkedHashSet;
21+
import java.util.Set;
22+
1923
import org.springframework.util.ClassUtils;
2024

2125
/**
@@ -26,6 +30,15 @@
2630
*/
2731
public abstract class AgentReloader {
2832

33+
private static final Set<String> AGENT_CLASSES;
34+
35+
static {
36+
Set<String> agentClasses = new LinkedHashSet<String>();
37+
agentClasses.add("org.zeroturnaround.javarebel.Integration");
38+
agentClasses.add("org.zeroturnaround.javarebel.ReloaderFactory");
39+
AGENT_CLASSES = Collections.unmodifiableSet(agentClasses);
40+
}
41+
2942
private AgentReloader() {
3043
}
3144

@@ -34,15 +47,17 @@ private AgentReloader() {
3447
* @return true if agent reloading is active
3548
*/
3649
public static boolean isActive() {
37-
return isJRebelActive();
50+
return isActive(null) || isActive(AgentReloader.class.getClassLoader())
51+
|| isActive(ClassLoader.getSystemClassLoader());
3852
}
3953

40-
/**
41-
* Determine if JRebel is active.
42-
* @return true if JRebel is active
43-
*/
44-
public static boolean isJRebelActive() {
45-
return ClassUtils.isPresent("org.zeroturnaround.javarebel.ReloaderFactory", null);
54+
private static boolean isActive(ClassLoader classLoader) {
55+
for (String agentClass : AGENT_CLASSES) {
56+
if (ClassUtils.isPresent(agentClass, classLoader)) {
57+
return true;
58+
}
59+
}
60+
return false;
4661
}
4762

4863
}

0 commit comments

Comments
 (0)