HoffmanZheng commented on code in PR #867:
URL:
https://github.com/apache/incubator-eventmesh/pull/867#discussion_r875452897
##########
eventmesh-trace-plugin/eventmesh-trace-zipkin/src/main/java/org/apache/eventmesh/trace/zipkin/ZipkinTraceService.java:
##########
@@ -92,7 +94,8 @@ public void init() {
.setTracerProvider(sdkTracerProvider)
.build();
- Runtime.getRuntime().addShutdownHook(new
Thread(sdkTracerProvider::close));
+ shutdownHook = new Thread(sdkTracerProvider::close);
+ Runtime.getRuntime().addShutdownHook(shutdownHook);
Review Comment:
> add a shutdown hook twice, then it throws an exception
the shutdown hook is already added in the `zipkinTraceService.init();`, thus
it throws exception in test as expected.
It ensures the `addShutdownHook` is called in the `init()` method, and the
`Thread(sdkTracerProvider::close)` is added there. If someone change the
behavior of that (e.g. remove the whole line
`Runtime.getRuntime().addShutdownHook(new Thread(sdkTracerProvider::close));`),
the unit test would fail.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]