无法通过bytebuddy检测threadPoolExecutor

问题描述 投票:0回答:1

我在这篇文章中遇到了同样的问题。

https://stackoverflow.com/questions/49321938/instrument-in-java-level-using-byte-buddy/55032131#55032131

当我使用代码仪器threadpoolexecutor时,

new AgentBuilder.Default()
            .ignore(ElementMatchers.none())
            .type(ElementMatchers.nameContains("ThreadPoolExecutor"))
            .transform((builder, type, classLoader, module) -> builder
                    .visit(Advice.to(ThreadPoolExecutorAdvice.class).on(ElementMatchers.any()))
            ).installOn(instrumentation);

我得到了这个错误,如何解决?

 java.lang.IllegalStateException: Cannot represent public org.apache.tomcat.util.threads.ThreadPoolExecutor(int,int,long,java.util.concurrent.TimeUnit,java.util.concurrent.BlockingQueue,java.util.concurrent.RejectedExecutionHandler) as given method constant
byte-buddy
1个回答
0
投票

您正在尝试在检测Method时注入Constructor实例。切换参数类型,它应该工作。

© www.soinside.com 2019 - 2024. All rights reserved.