Sonar fixes
Critical issues for `o.s.i.j*` (except `jdbc`).
This commit is contained in:
committed by
Artem Bilan
parent
89fdb938de
commit
7efe79f457
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.integration.core;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
@@ -31,6 +32,7 @@ public interface MessageSource<T> {
|
||||
* Returns <code>null</code> if no message is available.
|
||||
* @return The message or null.
|
||||
*/
|
||||
@Nullable
|
||||
Message<T> receive();
|
||||
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.springframework.integration.support.management.MessageSourceMetrics;
|
||||
import org.springframework.integration.support.management.metrics.CounterFacade;
|
||||
import org.springframework.integration.support.management.metrics.MetricsCaptor;
|
||||
import org.springframework.integration.util.AbstractExpressionEvaluator;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -231,6 +232,7 @@ public abstract class AbstractMessageSource<T> extends AbstractExpressionEvaluat
|
||||
* also can be {@link AbstractIntegrationMessageBuilder} which is used for additional headers population.
|
||||
* @return The value returned.
|
||||
*/
|
||||
@Nullable
|
||||
protected abstract Object doReceive();
|
||||
|
||||
@Override
|
||||
|
||||
@@ -393,7 +393,9 @@ public class CachingClientConnectionFactory extends AbstractClientConnectionFact
|
||||
|
||||
private final AtomicBoolean released = new AtomicBoolean();
|
||||
|
||||
private CachedConnection(TcpConnectionSupport connection, @Nullable TcpListener tcpListener) {
|
||||
private CachedConnection(TcpConnectionSupport connection, // NOSONAR false positive, not marked @Nullable
|
||||
@Nullable TcpListener tcpListener) {
|
||||
|
||||
super.setTheConnection(connection);
|
||||
registerListener(tcpListener);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.springframework.integration.endpoint.AbstractMessageSource;
|
||||
import org.springframework.integration.jms.util.JmsAdapterUtils;
|
||||
import org.springframework.integration.support.AbstractIntegrationMessageBuilder;
|
||||
import org.springframework.jms.core.JmsTemplate;
|
||||
import org.springframework.jms.support.converter.MessageConverter;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -131,7 +132,10 @@ public class JmsDestinationPollingSource extends AbstractMessageSource<Object> {
|
||||
Map<String, Object> mappedHeaders = this.headerMapper.toHeaders(jmsMessage);
|
||||
Object object = jmsMessage;
|
||||
if (this.extractPayload) {
|
||||
object = this.jmsTemplate.getMessageConverter().fromMessage(jmsMessage);
|
||||
MessageConverter converter = this.jmsTemplate.getMessageConverter();
|
||||
if (converter != null) {
|
||||
object = converter.fromMessage(jmsMessage);
|
||||
}
|
||||
}
|
||||
AbstractIntegrationMessageBuilder<?> builder =
|
||||
(object instanceof Message)
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.springframework.integration.dispatcher.UnicastingDispatcher;
|
||||
import org.springframework.integration.support.MessageBuilderFactory;
|
||||
import org.springframework.jms.core.JmsTemplate;
|
||||
import org.springframework.jms.listener.AbstractMessageListenerContainer;
|
||||
import org.springframework.jms.support.converter.MessageConverter;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageDeliveryException;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
@@ -206,14 +207,19 @@ public class SubscribableJmsChannel extends AbstractJmsChannel
|
||||
public void onMessage(javax.jms.Message message) {
|
||||
Message<?> messageToSend = null;
|
||||
try {
|
||||
Object converted = this.jmsTemplate.getMessageConverter().fromMessage(message);
|
||||
MessageConverter converter = this.jmsTemplate.getMessageConverter();
|
||||
Object converted = null;
|
||||
if (converter != null) {
|
||||
converted = converter.fromMessage(message);
|
||||
}
|
||||
if (converted != null) {
|
||||
messageToSend = (converted instanceof Message<?>) ? (Message<?>) converted
|
||||
: this.messageBuilderFactory.withPayload(converted).build();
|
||||
this.dispatcher.dispatch(messageToSend);
|
||||
}
|
||||
else if (this.logger.isWarnEnabled()) {
|
||||
this.logger.warn("MessageConverter returned null, no Message to dispatch");
|
||||
this.logger.warn("No converter found, or converter returned null for: " + message
|
||||
+ ", no Message to dispatch");
|
||||
}
|
||||
}
|
||||
catch (MessageDispatchingException e) {
|
||||
|
||||
@@ -24,6 +24,7 @@ import javax.jms.Destination;
|
||||
import javax.jms.ExceptionListener;
|
||||
import javax.jms.Session;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.config.AbstractFactoryBean;
|
||||
@@ -392,8 +393,9 @@ public class JmsChannelFactoryBean extends AbstractFactoryBean<AbstractJmsChanne
|
||||
this.channel.setInterceptors(this.interceptors);
|
||||
}
|
||||
this.channel.setBeanName(this.beanName);
|
||||
if (this.getBeanFactory() != null) {
|
||||
this.channel.setBeanFactory(this.getBeanFactory());
|
||||
BeanFactory beanFactory = this.getBeanFactory();
|
||||
if (beanFactory != null) {
|
||||
this.channel.setBeanFactory(beanFactory);
|
||||
}
|
||||
this.channel.afterPropertiesSet();
|
||||
return this.channel;
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.springframework.integration.jms.AbstractJmsChannel;
|
||||
import org.springframework.integration.jms.config.JmsChannelFactoryBean;
|
||||
import org.springframework.jms.support.converter.MessageConverter;
|
||||
import org.springframework.jms.support.destination.DestinationResolver;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* A {@link MessageChannelSpec} for an {@link AbstractJmsChannel}.
|
||||
@@ -33,6 +34,7 @@ import org.springframework.jms.support.destination.DestinationResolver;
|
||||
* @param <S> the target {@link JmsPollableMessageChannelSpec} implementation type.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
@@ -53,8 +55,10 @@ public class JmsPollableMessageChannelSpec<S extends JmsPollableMessageChannelSp
|
||||
}
|
||||
|
||||
@Override
|
||||
protected S id(String id) {
|
||||
this.jmsChannelFactoryBean.setBeanName(id);
|
||||
protected S id(@Nullable String id) {
|
||||
if (id != null) {
|
||||
this.jmsChannelFactoryBean.setBeanName(id);
|
||||
}
|
||||
return super.id(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -222,7 +222,7 @@ public class OperationInvokingMessageHandler extends AbstractReplyProducingMessa
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
private Map<String, Object> resolveParameters(Message<?> message) {
|
||||
Map<String, Object> map = null;
|
||||
Map<String, Object> map;
|
||||
if (message.getPayload() instanceof Map) {
|
||||
map = (Map<String, Object>) message.getPayload();
|
||||
}
|
||||
@@ -233,11 +233,8 @@ public class OperationInvokingMessageHandler extends AbstractReplyProducingMessa
|
||||
map = this.createParameterMapFromList(
|
||||
Arrays.asList(ObjectUtils.toObjectArray(message.getPayload())));
|
||||
}
|
||||
else if (message.getPayload() != null) {
|
||||
map = this.createParameterMapFromList(Collections.singletonList(message.getPayload()));
|
||||
}
|
||||
else {
|
||||
map = Collections.EMPTY_MAP;
|
||||
map = this.createParameterMapFromList(Collections.singletonList(message.getPayload()));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,6 +20,7 @@ import java.util.List;
|
||||
|
||||
import org.aopalliance.aop.Advice;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.config.AbstractFactoryBean;
|
||||
import org.springframework.integration.jpa.core.JpaExecutor;
|
||||
@@ -132,7 +133,10 @@ public class JpaOutboundGatewayFactoryBean extends AbstractFactoryBean<JpaOutbou
|
||||
if (this.adviceChain != null) {
|
||||
jpaOutboundGateway.setAdviceChain(this.adviceChain);
|
||||
}
|
||||
jpaOutboundGateway.setBeanFactory(this.getBeanFactory());
|
||||
BeanFactory beanFactory = getBeanFactory();
|
||||
if (beanFactory != null) {
|
||||
jpaOutboundGateway.setBeanFactory(beanFactory);
|
||||
}
|
||||
jpaOutboundGateway.afterPropertiesSet();
|
||||
return jpaOutboundGateway;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class JpaParameter {
|
||||
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.setExpression(expression);
|
||||
setExpression(expression);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,7 +79,7 @@ public class JpaParameter {
|
||||
*/
|
||||
public JpaParameter(@Nullable Object value, @Nullable String expression) {
|
||||
this.value = value;
|
||||
this.setExpression(expression);
|
||||
setExpression(expression);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@@ -90,6 +90,7 @@ public class JpaParameter {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Object getValue() {
|
||||
return this.value;
|
||||
}
|
||||
@@ -98,22 +99,27 @@ public class JpaParameter {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getExpression() {
|
||||
return this.expression;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Expression getSpelExpression() {
|
||||
return this.spelExpression;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Expression getProjectionExpression() {
|
||||
return this.projectionExpression;
|
||||
}
|
||||
|
||||
public final void setExpression(String expression) {
|
||||
this.expression = expression;
|
||||
this.spelExpression = PARSER.parseExpression(expression);
|
||||
this.projectionExpression = PARSER.parseExpression("#root.![" + expression + "]");
|
||||
public final void setExpression(@Nullable String expression) {
|
||||
if (expression != null) {
|
||||
this.expression = expression;
|
||||
this.spelExpression = PARSER.parseExpression(expression);
|
||||
this.projectionExpression = PARSER.parseExpression("#root.![" + expression + "]");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user