HoffmanZheng commented on code in PR #867:
URL: 
https://github.com/apache/incubator-eventmesh/pull/867#discussion_r875393725


##########
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:
   ^ to keep the reference to the shutdownHookThread, thus the behavior of 
`addShutdownHook` could be tested (it raise `Hook previously registered` when 
the same shutdownHookThread is added at second time).
   
   
https://github.com/apache/incubator-eventmesh/blob/6ea8944b8c91314b296acbb9ef107902c32b084d/eventmesh-trace-plugin/eventmesh-trace-zipkin/src/test/java/org/apache/eventmesh/trace/zipkin/ZipkinTraceServiceTest.java#L47-L55
   
   the `new Thread(sdkTracerProvider::close)` is not the same 
shutdownHookThread as previous, it could be added successfully and doesn't 
raise any exception (thus the behavior of `addShutdownHook` could not be 
tested).
   
   
https://github.com/apache/incubator-eventmesh/blob/836e3a5bd6a25c9831b0c6a8db30c997c68f0e91/eventmesh-trace-plugin/eventmesh-trace-zipkin/src/main/java/org/apache/eventmesh/trace/zipkin/ZipkinTraceService.java#L95



-- 
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]

Reply via email to