Skip to content
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

[Issue] AwaitingNonWebApplicationListener should not shutdown when Boostrap ApplicationContext is involved in Spring Cloud scenario #739

Closed
mercyblitz opened this issue Jul 22, 2020 · 0 comments
Assignees
Milestone

Comments

@mercyblitz
Copy link
Contributor

mercyblitz commented Jul 22, 2020

Spring Cloud Sample Code :

@EnableDiscoveryClient
@EnableAutoConfiguration
@EnableScheduling
@RefreshScope
public class DubboSpringCloudProviderBootstrap {

	@Autowired
	private ContextRefresher contextRefresher;

	@Scheduled(fixedDelay = 10 * 1000L)
	public void onScheduled() {
		contextRefresher.refreshEnvironment();
	}

	public static void main(String[] args) {
		new SpringApplicationBuilder(DubboSpringCloudProviderBootstrap.class)
				.properties("spring.profiles.active=zookeeper")
				.web(WebApplicationType.NONE).run(args);
	}

}

For org.springframework.cloud.context.refresh.ContextRefresher#addConfigFilesToEnvironment case:

		finally {
			ConfigurableApplicationContext closeable = capture;
			while (closeable != null) {
				try {
					closeable.close();
				}
				catch (Exception e) {
					// Ignore;
				}
				if (closeable.getParent() instanceof ConfigurableApplicationContext) {
					closeable = (ConfigurableApplicationContext) closeable.getParent();
				}
				else {
					break;
				}
			}
		}
@mercyblitz mercyblitz added this to the 2.7.8 milestone Jul 22, 2020
@mercyblitz mercyblitz self-assigned this Jul 22, 2020
@mercyblitz mercyblitz changed the title [Issue] AwaitingNonWebApplicationListener should not shutdown when ContextRefresher.refreshEnvironment() method is invoked in Spring Cloud scenario [Issue] AwaitingNonWebApplicationListener should not shutdown when Boostrap ApplicationContext is involved in Spring Cloud scenario Jul 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant