Fix sniff task warnings
This commit is contained in:
@@ -17,8 +17,6 @@
|
||||
package org.springframework.web.socket.config;
|
||||
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.web.socket.config.annotation.WebSocketConfigurationSupport;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
@@ -44,10 +42,6 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
*/
|
||||
class WebSocketNamespaceUtils {
|
||||
|
||||
// Check for setRemoveOnCancelPolicy method - available on JDK 7 and higher
|
||||
private static boolean hasRemoveOnCancelPolicyMethod = ClassUtils.hasMethod(
|
||||
ScheduledThreadPoolExecutor.class, "setRemoveOnCancelPolicy", boolean.class);
|
||||
|
||||
|
||||
public static RuntimeBeanReference registerHandshakeHandler(Element element, ParserContext parserContext, Object source) {
|
||||
RuntimeBeanReference handlerRef;
|
||||
@@ -149,9 +143,7 @@ class WebSocketNamespaceUtils {
|
||||
taskSchedulerDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
taskSchedulerDef.getPropertyValues().add("poolSize", Runtime.getRuntime().availableProcessors());
|
||||
taskSchedulerDef.getPropertyValues().add("threadNamePrefix", schedulerName + "-");
|
||||
if (hasRemoveOnCancelPolicyMethod) {
|
||||
taskSchedulerDef.getPropertyValues().add("removeOnCancelPolicy", true);
|
||||
}
|
||||
taskSchedulerDef.getPropertyValues().add("removeOnCancelPolicy", true);
|
||||
parserContext.getRegistry().registerBeanDefinition(schedulerName, taskSchedulerDef);
|
||||
parserContext.registerComponent(new BeanComponentDefinition(taskSchedulerDef, schedulerName));
|
||||
}
|
||||
|
||||
@@ -18,11 +18,8 @@ package org.springframework.web.socket.config.annotation;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.web.servlet.HandlerMapping;
|
||||
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
|
||||
/**
|
||||
* Configuration support for WebSocket request handling.
|
||||
*
|
||||
@@ -31,11 +28,6 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
*/
|
||||
public class WebSocketConfigurationSupport {
|
||||
|
||||
// Check for setRemoveOnCancelPolicy method - available on JDK 7 and higher
|
||||
private static boolean hasRemoveOnCancelPolicyMethod = ClassUtils.hasMethod(
|
||||
ScheduledThreadPoolExecutor.class, "setRemoveOnCancelPolicy", boolean.class);
|
||||
|
||||
|
||||
@Bean
|
||||
public HandlerMapping webSocketHandlerMapping() {
|
||||
ServletWebSocketHandlerRegistry registry = new ServletWebSocketHandlerRegistry(defaultSockJsTaskScheduler());
|
||||
@@ -68,9 +60,7 @@ public class WebSocketConfigurationSupport {
|
||||
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
|
||||
scheduler.setThreadNamePrefix("SockJS-");
|
||||
scheduler.setPoolSize(Runtime.getRuntime().availableProcessors());
|
||||
if (hasRemoveOnCancelPolicyMethod) {
|
||||
scheduler.setRemoveOnCancelPolicy(true);
|
||||
}
|
||||
scheduler.setRemoveOnCancelPolicy(true);
|
||||
return scheduler;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,14 +17,12 @@
|
||||
package org.springframework.web.socket.config.annotation;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
|
||||
import org.springframework.beans.factory.config.CustomScopeConfigurer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.messaging.simp.SimpSessionScope;
|
||||
import org.springframework.messaging.simp.config.AbstractMessageBrokerConfiguration;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.web.servlet.HandlerMapping;
|
||||
import org.springframework.web.socket.WebSocketHandler;
|
||||
import org.springframework.web.socket.messaging.SubProtocolWebSocketHandler;
|
||||
@@ -43,10 +41,6 @@ import org.springframework.web.socket.messaging.SubProtocolWebSocketHandler;
|
||||
*/
|
||||
public abstract class WebSocketMessageBrokerConfigurationSupport extends AbstractMessageBrokerConfiguration {
|
||||
|
||||
// Check for setRemoveOnCancelPolicy method - available on JDK 7 and higher
|
||||
private static boolean hasRemoveOnCancelPolicyMethod = ClassUtils.hasMethod(
|
||||
ScheduledThreadPoolExecutor.class, "setRemoveOnCancelPolicy", boolean.class);
|
||||
|
||||
private WebSocketTransportRegistration transportRegistration;
|
||||
|
||||
|
||||
@@ -104,9 +98,7 @@ public abstract class WebSocketMessageBrokerConfigurationSupport extends Abstrac
|
||||
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
|
||||
scheduler.setThreadNamePrefix("MessageBrokerSockJS-");
|
||||
scheduler.setPoolSize(Runtime.getRuntime().availableProcessors());
|
||||
if (hasRemoveOnCancelPolicyMethod) {
|
||||
scheduler.setRemoveOnCancelPolicy(true);
|
||||
}
|
||||
scheduler.setRemoveOnCancelPolicy(true);
|
||||
return scheduler;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user