Add missing check to avoid re-initialization

Noticed during review of #28736 that a check protecting against
re-initialization was accidentally removed in commit
3d6e38bb43.
This commit is contained in:
rstoyanchev 2022-07-04 16:17:57 +01:00
parent 22cc6c5918
commit 007bdede46
1 changed files with 8 additions and 6 deletions

View File

@ -84,6 +84,7 @@ public class WebSocketConfigurationSupport {
@Bean @Bean
@Nullable @Nullable
public TaskScheduler defaultSockJsTaskScheduler() { public TaskScheduler defaultSockJsTaskScheduler() {
if (this.scheduler == null) {
if (initHandlerRegistry().requiresTaskScheduler()) { if (initHandlerRegistry().requiresTaskScheduler()) {
ThreadPoolTaskScheduler threadPoolScheduler = new ThreadPoolTaskScheduler(); ThreadPoolTaskScheduler threadPoolScheduler = new ThreadPoolTaskScheduler();
threadPoolScheduler.setThreadNamePrefix("SockJS-"); threadPoolScheduler.setThreadNamePrefix("SockJS-");
@ -91,6 +92,7 @@ public class WebSocketConfigurationSupport {
threadPoolScheduler.setRemoveOnCancelPolicy(true); threadPoolScheduler.setRemoveOnCancelPolicy(true);
this.scheduler = threadPoolScheduler; this.scheduler = threadPoolScheduler;
} }
}
return this.scheduler; return this.scheduler;
} }