spring-cloud-commons icon indicating copy to clipboard operation
spring-cloud-commons copied to clipboard

Refreshing via ContextRefresher pins virtual threads

Open martinvisser opened this issue 1 year ago • 0 comments

Describe the bug With virtual threads enabled a call to /actuator/refresh pins virtual threads.

The ContextRefresher uses synchronized on both refresh and refreshEnvironment, so it seems they are not ready for use with virtual threads:

	public synchronized Set<String> refresh() {
		Set<String> keys = refreshEnvironment();
		this.scope.refreshAll();
		return keys;
	}

	public synchronized Set<String> refreshEnvironment() {
		Map<String, Object> before = extract(this.context.getEnvironment().getPropertySources());
		updateEnvironment();
		Set<String> keys = changes(before, extract(this.context.getEnvironment().getPropertySources())).keySet();
		this.context.publishEvent(new EnvironmentChangeEvent(this.context, keys));
		return keys;
	}

There could be more places of course

Are there plans to support virtual threads (with ReentrantLock)?

martinvisser avatar Oct 24 '24 08:10 martinvisser