From e2d891a32d7616fc13f5691e072fe1ce4f38c492 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Wed, 4 Sep 2019 11:40:23 -0400 Subject: [PATCH] Fix new Sonar smells --- .../integration/jpa/core/JpaExecutor.java | 11 ++++++----- .../rsocket/outbound/RSocketOutboundGateway.java | 7 +++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/core/JpaExecutor.java b/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/core/JpaExecutor.java index 7cd90faa58..e61f060efe 100644 --- a/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/core/JpaExecutor.java +++ b/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/core/JpaExecutor.java @@ -445,18 +445,19 @@ public class JpaExecutor implements InitializingBean, BeanFactoryAware { } private Object executeOutboundJpaOperationOnPersistentMode(Message message) { + Object payload = message.getPayload(); switch (this.persistMode) { case PERSIST: - this.jpaOperations.persist(message.getPayload(), this.flushSize, this.clearOnFlush); - return message.getPayload(); + this.jpaOperations.persist(payload, this.flushSize, this.clearOnFlush); + return payload; case MERGE: - return this.jpaOperations.merge(message.getPayload(), this.flushSize, this.clearOnFlush); + return this.jpaOperations.merge(payload, this.flushSize, this.clearOnFlush); case DELETE: - this.jpaOperations.delete(message.getPayload()); + this.jpaOperations.delete(payload); if (this.flush) { this.jpaOperations.flush(); } - return message.getPayload(); + return payload; default: throw new IllegalStateException("Unsupported PersistMode: " + this.persistMode.name()); } diff --git a/spring-integration-rsocket/src/main/java/org/springframework/integration/rsocket/outbound/RSocketOutboundGateway.java b/spring-integration-rsocket/src/main/java/org/springframework/integration/rsocket/outbound/RSocketOutboundGateway.java index 143587cd3f..a588877dd6 100644 --- a/spring-integration-rsocket/src/main/java/org/springframework/integration/rsocket/outbound/RSocketOutboundGateway.java +++ b/spring-integration-rsocket/src/main/java/org/springframework/integration/rsocket/outbound/RSocketOutboundGateway.java @@ -16,6 +16,7 @@ package org.springframework.integration.rsocket.outbound; +import java.util.Arrays; import java.util.Map; import org.reactivestreams.Publisher; @@ -95,9 +96,11 @@ public class RSocketOutboundGateway extends AbstractReplyProducingMessageHandler * @param route the RSocket endpoint route to use. * @param routeVariables the variables to expand route template. */ - public RSocketOutboundGateway(String route, Object... routeVariables) { + public RSocketOutboundGateway(String route, @Nullable Object... routeVariables) { this(new ValueExpression<>(route)); - this.routeVars = routeVariables; + if (routeVariables != null) { + this.routeVars = Arrays.copyOf(routeVariables, routeVariables.length); + } } /**