-
Notifications
You must be signed in to change notification settings - Fork 782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ZipkinAutoConfiguration executes the shutdown hook multiple times when using System.exit() #2199
Comments
Are all shutdown hooks called twice or only this one (e.g.: what if you register your own)? |
Sorry, my mistake, the shutdown-hook seems to behave correctly and is only executed once. So if I simplify our main application like this: package com.xxx.mybatch;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.context.ConfigurableApplicationContext;
@SpringBootApplication
@ConfigurationPropertiesScan
public class Application {
public static void main(String[] args) {
ConfigurableApplicationContext ctx = SpringApplication.run(Application.class, args);
SpringApplication.exit(ctx, () -> 0); // Still needed to shut down Spring once our CommandLineRunner is finished
}
} When the
But when the Java process is finally exiting, the shutdown hook is called trying to tear down the reporter again in this call stack:
And since the async reporter is already closed by Spring the flush method will throw this exception:
|
Maybe something got fixed in Zipkin and we no longer need to register the shutdown hook - we'll need to look into this |
Describe the bug
When using Zipkin in a Spring Boot batch application the shutdown hook here is called multiple times causing Zipkin to throw an exception. Should the shutdown hook be replaced with a
@PreDestroy
method?Exception:
Sample
Example program:
Versions
I am using:
The text was updated successfully, but these errors were encountered: