From 733b8955444b67b367887c2c0d6890d91d649d75 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Thu, 18 Jul 2019 10:35:12 -0400 Subject: [PATCH] Fix new Sonar smells * Remove redundant `@SafeVarargs` from `Disposables.add()` since `DisposableBean` is a "reifiable" type --- .../integration/config/annotation/Disposables.java | 11 ++++++----- .../integration/handler/LambdaMessageProcessor.java | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/Disposables.java b/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/Disposables.java index 33c23f3e6f..7a39f30aa3 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/Disposables.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/Disposables.java @@ -29,6 +29,8 @@ import org.springframework.beans.factory.DisposableBean; * case, the container does not automatically dispose of them. * * @author Gary Russell + * @author Artem Bilan + * * @since 5.1 * */ @@ -36,21 +38,20 @@ class Disposables implements DisposableBean { private final List disposables = new ArrayList<>(); - @SafeVarargs - @SuppressWarnings("varargs") public final void add(DisposableBean... disposablesToAdd) { this.disposables.addAll(Arrays.asList(disposablesToAdd)); } @Override public void destroy() { - this.disposables.forEach(d -> { + this.disposables.forEach((disposable) -> { try { - d.destroy(); + disposable.destroy(); } - catch (@SuppressWarnings("unused") Exception e) { + catch (@SuppressWarnings("unused") Exception ex) { // NOSONAR } }); } + } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/handler/LambdaMessageProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/handler/LambdaMessageProcessor.java index 56ca5d8c4a..d53443942d 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/handler/LambdaMessageProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/handler/LambdaMessageProcessor.java @@ -104,8 +104,8 @@ public class LambdaMessageProcessor implements MessageProcessor, BeanFac "An example of when this often occurs is if the lambda is configured to " + "receive a Message argument.", e.getCause()); } - throw new IllegalStateException( - "Could not invoke the method '" + this.method + "'", e.getCause()); // NOSONAR lost stack trace + throw new IllegalStateException( // NOSONAR lost stack trace + "Could not invoke the method '" + this.method + "'", e.getCause()); } catch (Exception e) { throw new IllegalStateException(