mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-05-02 12:03:41 +01:00
Fix warnings from sniff task on master
This commit is contained in:
+9
-1
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.web.socket.config;
|
||||
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
@@ -40,6 +41,11 @@ import org.springframework.web.socket.sockjs.transport.handler.WebSocketTranspor
|
||||
*/
|
||||
class WebSocketNamespaceUtils {
|
||||
|
||||
// Check for setRemoveOnCancelPolicy method - available on JDK 7 and higher
|
||||
private static boolean hasRemoveOnCancelPolicyMethod = ClassUtils.hasMethod(
|
||||
WebSocketNamespaceUtils.class, "setRemoveOnCancelPolicy", boolean.class);
|
||||
|
||||
|
||||
public static RuntimeBeanReference registerHandshakeHandler(Element element, ParserContext parserContext, Object source) {
|
||||
RuntimeBeanReference handlerRef;
|
||||
Element handlerElem = DomUtils.getChildElementByTagName(element, "handshake-handler");
|
||||
@@ -139,7 +145,9 @@ class WebSocketNamespaceUtils {
|
||||
taskSchedulerDef.setSource(source);
|
||||
taskSchedulerDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
taskSchedulerDef.getPropertyValues().add("poolSize", Runtime.getRuntime().availableProcessors());
|
||||
taskSchedulerDef.getPropertyValues().add("removeOnCancelPolicy", true);
|
||||
if (hasRemoveOnCancelPolicyMethod) {
|
||||
taskSchedulerDef.getPropertyValues().add("removeOnCancelPolicy", true);
|
||||
}
|
||||
taskSchedulerDef.getPropertyValues().add("threadNamePrefix", schedulerName + "-");
|
||||
parserContext.getRegistry().registerBeanDefinition(schedulerName, taskSchedulerDef);
|
||||
parserContext.registerComponent(new BeanComponentDefinition(taskSchedulerDef, schedulerName));
|
||||
|
||||
+9
-1
@@ -18,6 +18,7 @@ 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 org.springframework.web.servlet.handler.AbstractHandlerMapping;
|
||||
|
||||
@@ -29,6 +30,11 @@ import org.springframework.web.servlet.handler.AbstractHandlerMapping;
|
||||
*/
|
||||
public class WebSocketConfigurationSupport {
|
||||
|
||||
// Check for setRemoveOnCancelPolicy method - available on JDK 7 and higher
|
||||
private static boolean hasRemoveOnCancelPolicyMethod = ClassUtils.hasMethod(
|
||||
WebSocketConfigurationSupport.class, "setRemoveOnCancelPolicy", boolean.class);
|
||||
|
||||
|
||||
@Bean
|
||||
public HandlerMapping webSocketHandlerMapping() {
|
||||
ServletWebSocketHandlerRegistry registry = new ServletWebSocketHandlerRegistry(defaultSockJsTaskScheduler());
|
||||
@@ -63,7 +69,9 @@ public class WebSocketConfigurationSupport {
|
||||
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
|
||||
scheduler.setThreadNamePrefix("SockJS-");
|
||||
scheduler.setPoolSize(Runtime.getRuntime().availableProcessors());
|
||||
scheduler.setRemoveOnCancelPolicy(true);
|
||||
if (hasRemoveOnCancelPolicyMethod) {
|
||||
scheduler.setRemoveOnCancelPolicy(true);
|
||||
}
|
||||
return scheduler;
|
||||
}
|
||||
|
||||
|
||||
+9
-1
@@ -21,6 +21,7 @@ import org.springframework.messaging.simp.config.AbstractMessageBrokerConfigurat
|
||||
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
|
||||
import org.springframework.messaging.simp.user.UserSessionRegistry;
|
||||
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;
|
||||
@@ -38,6 +39,11 @@ 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(
|
||||
WebSocketConfigurationSupport.class, "setRemoveOnCancelPolicy", boolean.class);
|
||||
|
||||
|
||||
private WebSocketTransportRegistration transportRegistration;
|
||||
|
||||
|
||||
@@ -97,7 +103,9 @@ public abstract class WebSocketMessageBrokerConfigurationSupport extends Abstrac
|
||||
public ThreadPoolTaskScheduler messageBrokerSockJsTaskScheduler() {
|
||||
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
|
||||
scheduler.setPoolSize(Runtime.getRuntime().availableProcessors());
|
||||
scheduler.setRemoveOnCancelPolicy(true);
|
||||
if (hasRemoveOnCancelPolicyMethod) {
|
||||
scheduler.setRemoveOnCancelPolicy(true);
|
||||
}
|
||||
scheduler.setThreadNamePrefix("MessageBrokerSockJS-");
|
||||
return scheduler;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user