Skip to content

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

@mercyblitz

Description

@mercyblitz

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;
				}
			}
		}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions