JDBC, JMS, JPA Sonar fixes
This commit is contained in:
@@ -702,7 +702,7 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
|||||||
* @return the error message.
|
* @return the error message.
|
||||||
* @since 4.3.10
|
* @since 4.3.10
|
||||||
*/
|
*/
|
||||||
protected final ErrorMessage buildErrorMessage(Message<?> requestMessage, Throwable throwable) {
|
protected final ErrorMessage buildErrorMessage(@Nullable Message<?> requestMessage, Throwable throwable) {
|
||||||
return this.errorMessageStrategy.buildErrorMessage(throwable, getErrorMessageAttributes(requestMessage));
|
return this.errorMessageStrategy.buildErrorMessage(throwable, getErrorMessageAttributes(requestMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -33,6 +33,7 @@ import org.springframework.integration.expression.ExpressionUtils;
|
|||||||
import org.springframework.integration.support.DefaultMessageBuilderFactory;
|
import org.springframework.integration.support.DefaultMessageBuilderFactory;
|
||||||
import org.springframework.integration.support.MessageBuilderFactory;
|
import org.springframework.integration.support.MessageBuilderFactory;
|
||||||
import org.springframework.integration.support.utils.IntegrationUtils;
|
import org.springframework.integration.support.utils.IntegrationUtils;
|
||||||
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.messaging.Message;
|
import org.springframework.messaging.Message;
|
||||||
import org.springframework.messaging.MessageHandlingException;
|
import org.springframework.messaging.MessageHandlingException;
|
||||||
|
|
||||||
@@ -63,7 +64,7 @@ public abstract class AbstractExpressionEvaluator implements BeanFactoryAware, I
|
|||||||
* Specify a BeanFactory in order to enable resolution via <code>@beanName</code> in the expression.
|
* Specify a BeanFactory in order to enable resolution via <code>@beanName</code> in the expression.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setBeanFactory(final BeanFactory beanFactory) {
|
public void setBeanFactory(final @Nullable BeanFactory beanFactory) {
|
||||||
if (beanFactory != null) {
|
if (beanFactory != null) {
|
||||||
this.beanFactory = beanFactory;
|
this.beanFactory = beanFactory;
|
||||||
this.typeConverter.setBeanFactory(beanFactory);
|
this.typeConverter.setBeanFactory(beanFactory);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -48,6 +48,7 @@ import org.springframework.jdbc.core.simple.SimpleJdbcCallOperations;
|
|||||||
import org.springframework.jmx.export.annotation.ManagedAttribute;
|
import org.springframework.jmx.export.annotation.ManagedAttribute;
|
||||||
import org.springframework.jmx.export.annotation.ManagedMetric;
|
import org.springframework.jmx.export.annotation.ManagedMetric;
|
||||||
import org.springframework.jmx.export.annotation.ManagedResource;
|
import org.springframework.jmx.export.annotation.ManagedResource;
|
||||||
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.messaging.Message;
|
import org.springframework.messaging.Message;
|
||||||
import org.springframework.messaging.MessageHeaders;
|
import org.springframework.messaging.MessageHeaders;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
@@ -282,7 +283,7 @@ public class StoredProcExecutor implements BeanFactoryAware, InitializingBean {
|
|||||||
* @return Map containing the stored procedure results if any.
|
* @return Map containing the stored procedure results if any.
|
||||||
*/
|
*/
|
||||||
public Map<String, Object> executeStoredProcedure() {
|
public Map<String, Object> executeStoredProcedure() {
|
||||||
return executeStoredProcedureInternal(new Object(), this.evaluateExpression(null));
|
return executeStoredProcedureInternal(new Object(), evaluateExpression(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -311,9 +312,10 @@ public class StoredProcExecutor implements BeanFactoryAware, InitializingBean {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String evaluateExpression(Message<?> message) {
|
private String evaluateExpression(@Nullable Message<?> message) {
|
||||||
final String storedProcedureNameToUse = this.storedProcedureNameExpression.getValue(this.evaluationContext,
|
final String storedProcedureNameToUse = message == null
|
||||||
message, String.class);
|
? this.storedProcedureNameExpression.getValue(this.evaluationContext, String.class)
|
||||||
|
: this.storedProcedureNameExpression.getValue(this.evaluationContext, message, String.class);
|
||||||
|
|
||||||
Assert.hasText(storedProcedureNameToUse, String.format(
|
Assert.hasText(storedProcedureNameToUse, String.format(
|
||||||
"Unable to resolve Stored Procedure/Function name for the provided Expression '%s'.",
|
"Unable to resolve Stored Procedure/Function name for the provided Expression '%s'.",
|
||||||
|
|||||||
@@ -1416,11 +1416,11 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
|
|||||||
if (logger.isWarnEnabled()) {
|
if (logger.isWarnEnabled()) {
|
||||||
logger.warn("Unexpected error obtaining destination description: " + e.getMessage());
|
logger.warn("Unexpected error obtaining destination description: " + e.getMessage());
|
||||||
}
|
}
|
||||||
return null;
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return null;
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import javax.jms.Destination;
|
|||||||
import org.springframework.jms.core.JmsTemplate;
|
import org.springframework.jms.core.JmsTemplate;
|
||||||
import org.springframework.jms.listener.AbstractMessageListenerContainer;
|
import org.springframework.jms.listener.AbstractMessageListenerContainer;
|
||||||
import org.springframework.jms.listener.DefaultMessageListenerContainer;
|
import org.springframework.jms.listener.DefaultMessageListenerContainer;
|
||||||
|
import org.springframework.lang.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory class for JMS components.
|
* Factory class for JMS components.
|
||||||
@@ -48,7 +49,9 @@ public final class Jms {
|
|||||||
* @param connectionFactory the JMS ConnectionFactory to build on
|
* @param connectionFactory the JMS ConnectionFactory to build on
|
||||||
* @return the {@link JmsPollableMessageChannelSpec} instance
|
* @return the {@link JmsPollableMessageChannelSpec} instance
|
||||||
*/
|
*/
|
||||||
public static JmsPollableMessageChannelSpec<?> pollableChannel(String id, ConnectionFactory connectionFactory) {
|
public static JmsPollableMessageChannelSpec<?> pollableChannel(@Nullable String id,
|
||||||
|
ConnectionFactory connectionFactory) {
|
||||||
|
|
||||||
return new JmsPollableMessageChannelSpec<>(connectionFactory).id(id);
|
return new JmsPollableMessageChannelSpec<>(connectionFactory).id(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +70,7 @@ public final class Jms {
|
|||||||
* @param connectionFactory the JMS ConnectionFactory to build on
|
* @param connectionFactory the JMS ConnectionFactory to build on
|
||||||
* @return the {@link JmsMessageChannelSpec} instance
|
* @return the {@link JmsMessageChannelSpec} instance
|
||||||
*/
|
*/
|
||||||
public static JmsMessageChannelSpec<?> channel(String id, ConnectionFactory connectionFactory) {
|
public static JmsMessageChannelSpec<?> channel(@Nullable String id, ConnectionFactory connectionFactory) {
|
||||||
return new JmsMessageChannelSpec<>(connectionFactory)
|
return new JmsMessageChannelSpec<>(connectionFactory)
|
||||||
.id(id);
|
.id(id);
|
||||||
}
|
}
|
||||||
@@ -87,7 +90,7 @@ public final class Jms {
|
|||||||
* @param connectionFactory the JMS ConnectionFactory to build on
|
* @param connectionFactory the JMS ConnectionFactory to build on
|
||||||
* @return the {@link JmsPublishSubscribeMessageChannelSpec} instance
|
* @return the {@link JmsPublishSubscribeMessageChannelSpec} instance
|
||||||
*/
|
*/
|
||||||
public static JmsPublishSubscribeMessageChannelSpec publishSubscribeChannel(String id,
|
public static JmsPublishSubscribeMessageChannelSpec publishSubscribeChannel(@Nullable String id,
|
||||||
ConnectionFactory connectionFactory) {
|
ConnectionFactory connectionFactory) {
|
||||||
|
|
||||||
return new JmsPublishSubscribeMessageChannelSpec(connectionFactory).id(id);
|
return new JmsPublishSubscribeMessageChannelSpec(connectionFactory).id(id);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2017 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -19,6 +19,7 @@ package org.springframework.integration.jpa.support;
|
|||||||
import org.springframework.expression.Expression;
|
import org.springframework.expression.Expression;
|
||||||
import org.springframework.expression.ExpressionParser;
|
import org.springframework.expression.ExpressionParser;
|
||||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||||
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,7 +60,7 @@ public class JpaParameter {
|
|||||||
* @param value If null, the expression property must be set
|
* @param value If null, the expression property must be set
|
||||||
* @param expression If null, the value property must be set
|
* @param expression If null, the value property must be set
|
||||||
*/
|
*/
|
||||||
public JpaParameter(String name, Object value, String expression) {
|
public JpaParameter(String name, @Nullable Object value, @Nullable String expression) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
Assert.hasText(name, "'name' must not be empty.");
|
Assert.hasText(name, "'name' must not be empty.");
|
||||||
@@ -76,7 +77,7 @@ public class JpaParameter {
|
|||||||
* @param value If null, the expression property must be set
|
* @param value If null, the expression property must be set
|
||||||
* @param expression If null, the value property must be set
|
* @param expression If null, the value property must be set
|
||||||
*/
|
*/
|
||||||
public JpaParameter(Object value, String expression) {
|
public JpaParameter(@Nullable Object value, @Nullable String expression) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.setExpression(expression);
|
this.setExpression(expression);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import org.springframework.expression.Expression;
|
|||||||
import org.springframework.expression.ExpressionException;
|
import org.springframework.expression.ExpressionException;
|
||||||
import org.springframework.integration.jpa.support.JpaParameter;
|
import org.springframework.integration.jpa.support.JpaParameter;
|
||||||
import org.springframework.integration.jpa.support.parametersource.ExpressionEvaluatingParameterSourceUtils.ParameterExpressionEvaluator;
|
import org.springframework.integration.jpa.support.parametersource.ExpressionEvaluatingParameterSourceUtils.ParameterExpressionEvaluator;
|
||||||
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,7 +56,7 @@ public class ExpressionEvaluatingParameterSourceFactory implements ParameterSour
|
|||||||
this(null);
|
this(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExpressionEvaluatingParameterSourceFactory(BeanFactory beanFactory) {
|
public ExpressionEvaluatingParameterSourceFactory(@Nullable BeanFactory beanFactory) {
|
||||||
this.parameters = new ArrayList<>();
|
this.parameters = new ArrayList<>();
|
||||||
this.expressionEvaluator.setBeanFactory(beanFactory);
|
this.expressionEvaluator.setBeanFactory(beanFactory);
|
||||||
}
|
}
|
||||||
@@ -78,6 +79,7 @@ public class ExpressionEvaluatingParameterSourceFactory implements ParameterSour
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public PositionSupportingParameterSource createParameterSource(final Object input) {
|
public PositionSupportingParameterSource createParameterSource(final Object input) {
|
||||||
return new ExpressionEvaluatingParameterSource(input, this.parameters, this.expressionEvaluator);
|
return new ExpressionEvaluatingParameterSource(input, this.parameters, this.expressionEvaluator);
|
||||||
}
|
}
|
||||||
@@ -109,6 +111,7 @@ public class ExpressionEvaluatingParameterSourceFactory implements ParameterSour
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getValueByPosition(int position) {
|
public Object getValueByPosition(int position) {
|
||||||
|
|
||||||
Assert.isTrue(position >= 0, "The position must be non-negative.");
|
Assert.isTrue(position >= 0, "The position must be non-negative.");
|
||||||
@@ -148,6 +151,7 @@ public class ExpressionEvaluatingParameterSourceFactory implements ParameterSour
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getValue(String paramName) {
|
public Object getValue(String paramName) {
|
||||||
if (this.values.containsKey(paramName)) {
|
if (this.values.containsKey(paramName)) {
|
||||||
return this.values.get(paramName);
|
return this.values.get(paramName);
|
||||||
@@ -178,6 +182,7 @@ public class ExpressionEvaluatingParameterSourceFactory implements ParameterSour
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean hasValue(String paramName) {
|
public boolean hasValue(String paramName) {
|
||||||
try {
|
try {
|
||||||
final Object value = getValue(paramName);
|
final Object value = getValue(paramName);
|
||||||
|
|||||||
Reference in New Issue
Block a user