From 94e65215106ca608d8a0f4565a66b979fc8001bf Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Wed, 7 Oct 2020 12:31:44 -0400 Subject: [PATCH] Fix some new Sonar smells --- .../tcp/connection/TcpNetServerConnectionFactory.java | 2 +- .../integration/test/mail/TestMailServer.java | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) 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 187c8ea628..6e2429c0b7 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 @@ -175,7 +175,7 @@ public class TcpNetServerConnectionFactory extends AbstractServerConnectionFacto } } } - catch (IOException ex) { + 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 logger.info("Server Socket closed"); 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 789ccb544f..9e0bdf9b1f 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 @@ -177,12 +177,15 @@ public final class TestMailServer { super(socket); } - @Override + @Override // NOSONAR void doRun() { try { write("+OK POP3"); while (!socket.isClosed()) { String line = reader.readLine(); + if (line == null) { + break; + } switch (line) { case "CAPA": write(PLUS_OK); @@ -206,6 +209,8 @@ public final class TestMailServer { write(PLUS_OK); socket.close(); break; + default: + throw new UnsupportedOperationException(line); } } } @@ -255,8 +260,7 @@ public final class TestMailServer { super(socket); } - @Override - // NOSONAR + @Override // NOSONAR void doRun() { try { write("* OK IMAP4rev1 Service Ready");