Skip to content

[Bug] Guava-eventbus-plugin throw NPE. #10967

@xzyJavaX

Description

@xzyJavaX

Search before asking

  • I had searched in the issues and found no similar issues.

Apache SkyWalking Component

Java Agent (apache/skywalking-java)

What happened

Guava-eventbus-plugin throw NPE.
Error log:

ERROR 2023-06-20 14:42:44.402 Thread-3 InstMethodsInterWithOverrideArgs : class[class com.google.common.eventbus.Dispatcher$LegacyAsyncDispatcher] before method[dispatch] intercept failure 
java.lang.NullPointerException: Cannot invoke "org.apache.skywalking.apm.agent.core.context.AbstractTracerContext.capture()" because the return value of "org.apache.skywalking.apm.agent.core.context.ContextManager.get()" is null
	at org.apache.skywalking.apm.agent.core.context.ContextManager.capture(ContextManager.java:158)
	at org.apache.skywalking.apm.plugin.guava.eventbus.EventBusDispatchInterceptor.beforeMethod(EventBusDispatchInterceptor.java:38)
	at org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstMethodsInterWithOverrideArgs.intercept(InstMethodsInterWithOverrideArgs.java:75)
	at com.google.common.eventbus.Dispatcher$LegacyAsyncDispatcher.dispatch(Dispatcher.java)
	at com.google.common.eventbus.EventBus.post(EventBus.java:215)
	at com.wosai.middleware.samples.hera.controller.CaseController.lambda$testcase$0(CaseController.java:54)
	at java.base/java.lang.Thread.run(Thread.java:833)

What you expected to happen

No response

How to reproduce

    private final AsyncEventBus asyncEventBus = new AsyncEventBus(Executors.newFixedThreadPool(5));
    @Resource
    private SubscriberService subscriberService;

    @RequestMapping("/guava-scenario")
    @ResponseBody
    public void testcase(HttpServletRequest request) throws Exception {
        asyncEventBus.register(subscriberService);
        final TestEvent testEvent = new TestEvent();
        testEvent.setContent("test");
        new Thread(() -> asyncEventBus.post(testEvent)).start();
    }

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Labels

agentLanguage agent related.bugSomething isn't working and you are sure it's a bug!pluginPlugin for agent or collector. Be used to extend the capabilities of default implementor.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions