Fix sniff task warnings
This commit is contained in:
@@ -137,6 +137,7 @@ public class ScheduledExecutorFactoryBean extends ExecutorConfigurationSupport
|
||||
|
||||
|
||||
@Override
|
||||
@UsesJava7
|
||||
protected ExecutorService initializeExecutor(
|
||||
ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) {
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.core.task.AsyncListenableTaskExecutor;
|
||||
import org.springframework.core.task.TaskRejectedException;
|
||||
import org.springframework.lang.UsesJava7;
|
||||
import org.springframework.scheduling.SchedulingTaskExecutor;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.scheduling.Trigger;
|
||||
@@ -83,6 +84,7 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
|
||||
* There is no default. If not set, the executor property is not set.
|
||||
* <p><b>This setting can be modified at runtime, for example through JMX.</b>
|
||||
*/
|
||||
@UsesJava7
|
||||
public void setRemoveOnCancelPolicy(boolean removeOnCancelPolicy) {
|
||||
this.removeOnCancelPolicy = removeOnCancelPolicy;
|
||||
if (this.scheduledExecutor instanceof ScheduledThreadPoolExecutor) {
|
||||
@@ -98,6 +100,7 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
|
||||
this.errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
@UsesJava7
|
||||
@Override
|
||||
protected ExecutorService initializeExecutor(
|
||||
ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) {
|
||||
@@ -169,6 +172,7 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
|
||||
* Return the current setting of removeOnCancelPolicy.
|
||||
* <p>Requires an underlying {@link ScheduledThreadPoolExecutor} and JDK 1.7+.
|
||||
*/
|
||||
@UsesJava7
|
||||
public boolean isRemoveOnCancelPolicy() {
|
||||
if (this.scheduledExecutor == null) {
|
||||
// Not initialized yet: return false (the default of the executor)
|
||||
|
||||
@@ -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