Fix new Sonar smells (#2768)

* Fix new Sonar smells

* Fix some old Sonar smells as well
* Fix Micrometer leaks in the `PollableChannel` when we register
meters, but don't remove them.

* * Fix NPE around `MetricsCaptor` in channels

* * Fix new smells according test report

* * Further Sonar smell fixes

* * More smell fixes for `MessagingMethodInvokerHelper`
* Remove `throws Exception` from `AbstractMessageHandler.destroy()`

* * Fix complexity in the `MessagingMethodInvokerHelper.processInvokeExceptionAndFallbackToExpressionIfAny()`
This commit is contained in:
Artem Bilan
2019-02-27 15:17:51 -05:00
committed by Gary Russell
parent f741724656
commit d2e974a6de
33 changed files with 828 additions and 750 deletions

View File

@@ -63,6 +63,8 @@ import org.springframework.util.StringUtils;
public class UnicastSendingMessageHandler extends
AbstractInternetProtocolSendingMessageHandler implements Runnable {
private static final int DEFAULT_ACK_TIMEOUT = 5000;
private final DatagramPacketMessageMapper mapper = new DatagramPacketMessageMapper();
private final Expression destinationExpression;
@@ -80,12 +82,11 @@ public class UnicastSendingMessageHandler extends
private volatile int ackPort;
private volatile int ackTimeout = 5000;
private volatile int ackTimeout = DEFAULT_ACK_TIMEOUT;
private volatile int ackCounter = 1;
private volatile Map<String, CountDownLatch> ackControl =
Collections.synchronizedMap(new HashMap<String, CountDownLatch>());
private volatile Map<String, CountDownLatch> ackControl = Collections.synchronizedMap(new HashMap<>());
private volatile int soReceiveBufferSize = -1;
@@ -283,7 +284,7 @@ public class UnicastSendingMessageHandler extends
}
}
catch (Exception ex) {
if (!(ex instanceof MessagingException)) {
if (!(ex instanceof MessagingException)) { // NOSONAR
closeSocketIfNeeded();
}
throw IntegrationUtils.wrapInHandlingExceptionIfNecessary(message,