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

@@ -197,8 +197,13 @@ public class SubscribableRedisChannel extends AbstractMessageChannel
}
@Override
public void destroy() throws Exception {
this.container.destroy();
public void destroy() {
try {
this.container.destroy();
}
catch (Exception ex) {
throw new IllegalStateException("Cannot destroy " + this.container, ex);
}
}
private class MessageListenerDelegate {
@@ -217,11 +222,11 @@ public class SubscribableRedisChannel extends AbstractMessageChannel
String exceptionMessage = e.getMessage();
throw new MessageDeliveryException(siMessage,
(exceptionMessage == null ? e.getClass().getSimpleName() : exceptionMessage)
+ " for redis-channel '"
+ (StringUtils.hasText(SubscribableRedisChannel.this.topicName)
+ " for redis-channel '"
+ (StringUtils.hasText(SubscribableRedisChannel.this.topicName)
? SubscribableRedisChannel.this.topicName
: "unknown")
+ "' (" + getFullChannelName() + ").", e); // NOSONAR false positive - never null
+ "' (" + getFullChannelName() + ").", e); // NOSONAR false positive - never null
}
}