Fix more deprecations around TaskScheduler
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2021 the original author or authors.
|
||||
* Copyright 2001-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.integration.ip.tcp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
@@ -440,11 +440,12 @@ public class TcpOutboundGateway extends AbstractReplyProducingMessageHandler
|
||||
this.connection = connection;
|
||||
this.haveSemaphore = haveSemaphore;
|
||||
if (async && remoteTimeout > 0) {
|
||||
getTaskScheduler().schedule(() -> {
|
||||
TcpOutboundGateway.this.pendingReplies.remove(connection.getConnectionId());
|
||||
this.future.setException(
|
||||
new MessageTimeoutException(requestMessage, "Timed out waiting for response"));
|
||||
}, new Date(System.currentTimeMillis() + remoteTimeout));
|
||||
getTaskScheduler()
|
||||
.schedule(() -> {
|
||||
TcpOutboundGateway.this.pendingReplies.remove(connection.getConnectionId());
|
||||
this.future.setException(
|
||||
new MessageTimeoutException(requestMessage, "Timed out waiting for response"));
|
||||
}, Instant.now().plusMillis(remoteTimeout));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.integration.ip.tcp;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@@ -72,7 +73,7 @@ public class TcpReceivingChannelAdapter
|
||||
boolean isErrorMessage = message instanceof ErrorMessage;
|
||||
try {
|
||||
if (this.shuttingDown) {
|
||||
logger.info(() -> "Inbound message ignored; shutting down; " + message.toString());
|
||||
logger.info(() -> "Inbound message ignored; shutting down; " + message);
|
||||
}
|
||||
else {
|
||||
if (isErrorMessage) {
|
||||
@@ -134,7 +135,7 @@ public class TcpReceivingChannelAdapter
|
||||
this.clientModeConnectionManager = manager;
|
||||
TaskScheduler taskScheduler = getTaskScheduler();
|
||||
Assert.state(taskScheduler != null, "Client mode requires a task scheduler");
|
||||
this.scheduledFuture = taskScheduler.scheduleAtFixedRate(manager, this.retryInterval);
|
||||
this.scheduledFuture = taskScheduler.scheduleAtFixedRate(manager, Duration.ofMillis(this.retryInterval));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.integration.ip.tcp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
@@ -267,7 +268,8 @@ public class TcpSendingMessageHandler extends AbstractMessageHandler implements
|
||||
this.clientModeConnectionManager = manager;
|
||||
TaskScheduler taskScheduler = getTaskScheduler();
|
||||
Assert.state(taskScheduler != null, "Client mode requires a task scheduler");
|
||||
this.scheduledFuture = taskScheduler.scheduleAtFixedRate(manager, this.retryInterval);
|
||||
this.scheduledFuture =
|
||||
taskScheduler.scheduleAtFixedRate(manager, Duration.ofMillis(this.retryInterval));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2020 the original author or authors.
|
||||
* Copyright 2001-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,7 +20,7 @@ import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.SocketException;
|
||||
import java.util.Date;
|
||||
import java.time.Instant;
|
||||
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.core.task.TaskRejectedException;
|
||||
@@ -56,7 +56,6 @@ public abstract class AbstractServerConnectionFactory extends AbstractConnection
|
||||
|
||||
/**
|
||||
* The port on which the factory will listen.
|
||||
*
|
||||
* @param port The port.
|
||||
*/
|
||||
public AbstractServerConnectionFactory(int port) {
|
||||
@@ -201,10 +200,10 @@ public abstract class AbstractServerConnectionFactory extends AbstractConnection
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected void publishServerExceptionEvent(Exception e) {
|
||||
protected void publishServerExceptionEvent(Exception ex) {
|
||||
ApplicationEventPublisher applicationEventPublisher = getApplicationEventPublisher();
|
||||
if (applicationEventPublisher != null) {
|
||||
applicationEventPublisher.publishEvent(new TcpConnectionServerExceptionEvent(this, e));
|
||||
applicationEventPublisher.publishEvent(new TcpConnectionServerExceptionEvent(this, ex));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,7 +214,7 @@ public abstract class AbstractServerConnectionFactory extends AbstractConnection
|
||||
TaskScheduler taskScheduler = getTaskScheduler();
|
||||
if (taskScheduler != null) {
|
||||
try {
|
||||
taskScheduler.schedule(() -> eventPublisher.publishEvent(event), new Date());
|
||||
taskScheduler.schedule(() -> eventPublisher.publishEvent(event), Instant.now());
|
||||
}
|
||||
catch (@SuppressWarnings("unused") TaskRejectedException e) {
|
||||
eventPublisher.publishEvent(event);
|
||||
|
||||
Reference in New Issue
Block a user