spring-cloud-commons
spring-cloud-commons copied to clipboard
Refreshing via ContextRefresher pins virtual threads
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)?