INT-4108: Fix idempotency for some Lifecycles
JIRA: https://jira.spring.io/browse/INT-4108 Some `Lifecycle.start()/stop()` usage doesn't ensure robustness for components causing unexpected and difficulty tracing issues * Fix `Lifecycle.start()/stop()` for `FileReadingMessageSource`, `FileWritingMessageHandler`, `AbstractMqttMessageHandler` * In the `DefaultHeaderChannelRegistry`, `LockRegistryLeaderInitiator`, `MqttPahoMessageHandler` rework logic for shared variables to avoid `NPE` * Increase receive timeouts in the `PayloadDeserializingTransformerParserTests` and `UdpChannelAdapterTests` * Prove with the `WatchServiceDirectoryScannerTests` changes that several invocation for `FileReadingMessageSource.start()` are idempotent **Cherry-pick to 4.3.x**
This commit is contained in:
@@ -197,7 +197,7 @@ public class UdpChannelAdapterTests {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
Message<byte[]> receivedMessage = (Message<byte[]>) channel.receive(2000);
|
||||
Message<byte[]> receivedMessage = (Message<byte[]>) channel.receive(10000);
|
||||
assertEquals(new String(message.getPayload()), new String(receivedMessage.getPayload()));
|
||||
String replyString = "reply:" + System.currentTimeMillis();
|
||||
byte[] replyBytes = replyString.getBytes();
|
||||
@@ -241,7 +241,7 @@ public class UdpChannelAdapterTests {
|
||||
handler.start();
|
||||
Message<byte[]> message = MessageBuilder.withPayload("ABCD".getBytes()).build();
|
||||
handler.handleMessage(message);
|
||||
Message<byte[]> receivedMessage = (Message<byte[]>) channel.receive(2000);
|
||||
Message<byte[]> receivedMessage = (Message<byte[]>) channel.receive(10000);
|
||||
assertEquals(new String(message.getPayload()), new String(receivedMessage.getPayload()));
|
||||
adapter.stop();
|
||||
handler.stop();
|
||||
@@ -268,7 +268,7 @@ public class UdpChannelAdapterTests {
|
||||
datagramSocket.send(packet);
|
||||
datagramSocket.close();
|
||||
|
||||
Message<byte[]> receivedMessage = (Message<byte[]>) channel.receive(2000);
|
||||
Message<byte[]> receivedMessage = (Message<byte[]>) channel.receive(10000);
|
||||
assertNotNull(receivedMessage);
|
||||
assertEquals(new String(message.getPayload()), new String(receivedMessage.getPayload()));
|
||||
adapter.stop();
|
||||
@@ -292,7 +292,7 @@ public class UdpChannelAdapterTests {
|
||||
Message<byte[]> message = MessageBuilder.withPayload("ABCD".getBytes()).build();
|
||||
handler.handleMessage(message);
|
||||
|
||||
Message<byte[]> receivedMessage = (Message<byte[]>) channel.receive(2000);
|
||||
Message<byte[]> receivedMessage = (Message<byte[]>) channel.receive(10000);
|
||||
assertNotNull(receivedMessage);
|
||||
assertEquals(new String(message.getPayload()), new String(receivedMessage.getPayload()));
|
||||
adapter.stop();
|
||||
@@ -320,7 +320,7 @@ public class UdpChannelAdapterTests {
|
||||
DatagramSocket datagramSocket = new DatagramSocket(0);
|
||||
datagramSocket.send(packet);
|
||||
datagramSocket.close();
|
||||
Message<?> receivedMessage = errorChannel.receive(2000);
|
||||
Message<?> receivedMessage = errorChannel.receive(10000);
|
||||
assertNotNull(receivedMessage);
|
||||
assertEquals("Failed", ((Exception) receivedMessage.getPayload()).getCause().getMessage());
|
||||
adapter.stop();
|
||||
|
||||
Reference in New Issue
Block a user