Skip to content

Commit 66817b7

Browse files
committed
* Improve TcpInboundGateway logic to check for connectionFactory is set in the onInit()
* Improve `UnicastSendingMessageHandler.restartAckThread()` to reflect the proper state of the `UnicastSendingMessageHandler`
1 parent d82e537 commit 66817b7

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/TcpInboundGateway.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ public String getComponentType() {
203203
@Override
204204
protected void onInit() {
205205
super.onInit();
206+
Assert.state(this.serverConnectionFactory != null || this.clientConnectionFactory != null,
207+
"An 'AbstractConnectionFactory' must not be provided.");
206208
if (this.isClientMode) {
207209
Assert.notNull(this.clientConnectionFactory, "For client-mode, connection factory must be type='client'");
208210
Assert.isTrue(!this.clientConnectionFactory.isSingleUse(),

spring-integration-ip/src/main/java/org/springframework/integration/ip/udp/UnicastSendingMessageHandler.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ protected void doStop() {
282282
@Override
283283
public void handleMessageInternal(Message<?> message) {
284284
if (this.acknowledge) {
285-
Assert.state(this.isRunning(), "When 'acknowledge' is enabled, adapter must be running");
285+
Assert.state(isRunning(), "When 'acknowledge' is enabled, adapter must be running");
286286
startAckThread();
287287
}
288288
CountDownLatch countdownLatch = null;
@@ -568,9 +568,11 @@ public void run() {
568568
* (bind) error occurred, without bouncing the JVM.
569569
*/
570570
public void restartAckThread() {
571-
if (this.taskExecutor != null) {
572-
this.taskExecutor.execute(this);
573-
}
571+
Assert.state(this.acknowledge,
572+
"The UnicastSendingMessageHandler has to be in the 'acknowledgment' mode to run ack thread.");
573+
Assert.state(this.taskExecutor != null,
574+
"The UnicastSendingMessageHandler is not running to schedule an ack thread.");
575+
this.taskExecutor.execute(this);
574576
}
575577

576578
private void closeSocketIfNeeded() {

0 commit comments

Comments
 (0)