diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/FluxMessageChannel.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/FluxMessageChannel.java index 0d09425c47..90f41694d8 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/channel/FluxMessageChannel.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/FluxMessageChannel.java @@ -105,7 +105,7 @@ public class FluxMessageChannel extends AbstractMessageChannel .filter(Boolean::booleanValue) .doOnNext(this.subscribedSignal::tryEmitNext) .repeatWhenEmpty((repeat) -> - this.active ? repeat.delayElements(Duration.ofMillis(100)) : repeat) + this.active ? repeat.delayElements(Duration.ofMillis(100)) : repeat) // NOSONAR .subscribe()); } diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNetServerConnectionFactory.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNetServerConnectionFactory.java index 6e2429c0b7..d9e6c9124c 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNetServerConnectionFactory.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNetServerConnectionFactory.java @@ -105,24 +105,12 @@ public class TcpNetServerConnectionFactory extends AbstractServerConnectionFacto */ @Override public void run() { - ServerSocket theServerSocket = null; if (getListener() == null) { logger.info(() -> this + " No listener bound to server connection factory; will not read; exiting..."); return; } try { - if (getLocalAddress() == null) { - theServerSocket = createServerSocket(super.getPort(), getBacklog(), null); - } - else { - InetAddress whichNic = InetAddress.getByName(getLocalAddress()); - theServerSocket = createServerSocket(super.getPort(), getBacklog(), whichNic); - } - getTcpSocketSupport().postProcessServerSocket(theServerSocket); - this.serverSocket = theServerSocket; - setListening(true); - logger.info(() -> this + " Listening"); - publishServerListeningEvent(getPort()); + setupServerSocket(); while (true) { final Socket socket; /* @@ -177,7 +165,7 @@ public class TcpNetServerConnectionFactory extends AbstractServerConnectionFacto } catch (IOException ex) { // NOSONAR flow control via exceptions // don't log an error if we had a good socket once and now it's closed - if (ex instanceof SocketException && theServerSocket != null) { // NOSONAR flow control via exceptions + if (ex instanceof SocketException && this.serverSocket != null) { // NOSONAR flow control via exceptions logger.info("Server Socket closed"); } else if (isActive()) { @@ -192,6 +180,22 @@ public class TcpNetServerConnectionFactory extends AbstractServerConnectionFacto } } + private void setupServerSocket() throws IOException { + ServerSocket theServerSocket; + if (getLocalAddress() == null) { + theServerSocket = createServerSocket(super.getPort(), getBacklog(), null); + } + else { + InetAddress whichNic = InetAddress.getByName(getLocalAddress()); + theServerSocket = createServerSocket(super.getPort(), getBacklog(), whichNic); + } + getTcpSocketSupport().postProcessServerSocket(theServerSocket); + this.serverSocket = theServerSocket; + setListening(true); + logger.info(() -> this + " Listening"); + publishServerListeningEvent(getPort()); + } + /** * Create a new {@link ServerSocket}. This default implementation uses the default * {@link ServerSocketFactory}. Override to use some other mechanism diff --git a/spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/inbound/MqttPahoMessageDrivenChannelAdapter.java b/spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/inbound/MqttPahoMessageDrivenChannelAdapter.java index 6c134118ce..8b54218b5f 100644 --- a/spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/inbound/MqttPahoMessageDrivenChannelAdapter.java +++ b/spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/inbound/MqttPahoMessageDrivenChannelAdapter.java @@ -302,14 +302,7 @@ public class MqttPahoMessageDrivenChannelAdapter extends AbstractMqttMessageDriv int[] requestedQos = getQos(); int[] grantedQos = Arrays.copyOf(requestedQos, requestedQos.length); this.client.subscribe(topics, grantedQos); - for (int i = 0; i < requestedQos.length; i++) { - if (grantedQos[i] != requestedQos[i]) { - logger.warn(() -> "Granted QOS different to Requested QOS; topics: " + Arrays.toString(topics) - + " requested: " + Arrays.toString(requestedQos) - + " granted: " + Arrays.toString(grantedQos)); - break; - } - } + warnInvalidQosForSubscription(topics, requestedQos, grantedQos); } catch (MqttException ex) { if (this.applicationEventPublisher != null) { @@ -340,6 +333,17 @@ public class MqttPahoMessageDrivenChannelAdapter extends AbstractMqttMessageDriv } } + private void warnInvalidQosForSubscription(String[] topics, int[] requestedQos, int[] grantedQos) { + for (int i = 0; i < requestedQos.length; i++) { + if (grantedQos[i] != requestedQos[i]) { + logger.warn(() -> "Granted QOS different to Requested QOS; topics: " + Arrays.toString(topics) + + " requested: " + Arrays.toString(requestedQos) + + " granted: " + Arrays.toString(grantedQos)); + break; + } + } + } + private synchronized void cancelReconnect() { if (this.reconnectFuture != null) { this.reconnectFuture.cancel(false); diff --git a/spring-integration-test-support/src/main/java/org/springframework/integration/test/mail/TestMailServer.java b/spring-integration-test-support/src/main/java/org/springframework/integration/test/mail/TestMailServer.java index 9e0bdf9b1f..d9ad5e45f3 100644 --- a/spring-integration-test-support/src/main/java/org/springframework/integration/test/mail/TestMailServer.java +++ b/spring-integration-test-support/src/main/java/org/springframework/integration/test/mail/TestMailServer.java @@ -391,7 +391,7 @@ public final class TestMailServer { LOGGER.error(IO_EXCEPTION, e); } } - } + } // NOSONAR void searchReply(String tag) throws IOException { if (seen) {