Sonar Fixes
Critical smells, packages `o.s.i.a*` to `f*`. Plus new smells caused by these changes.
This commit is contained in:
committed by
Artem Bilan
parent
4ade0ceaf4
commit
62fc7df693
@@ -131,7 +131,7 @@ subprojects { subproject ->
|
||||
romeToolsVersion = '1.9.0'
|
||||
servletApiVersion = '4.0.0'
|
||||
smackVersion = '4.3.1'
|
||||
springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '2.1.2.RELEASE'
|
||||
springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '2.1.3.BUILD-SNAPSHOT'
|
||||
springDataJpaVersion = '2.1.3.RELEASE'
|
||||
springDataMongoVersion = '2.1.3.RELEASE'
|
||||
springDataRedisVersion = '2.1.3.RELEASE'
|
||||
|
||||
@@ -288,14 +288,9 @@ abstract class AbstractSubscribableAmqpChannel extends AbstractAmqpChannel
|
||||
Message<?> messageToSend = null;
|
||||
try {
|
||||
Object converted = this.converter.fromMessage(message);
|
||||
if (converted != null) {
|
||||
messageToSend = (converted instanceof Message<?>) ? (Message<?>) converted
|
||||
: buildMessage(message, converted);
|
||||
this.dispatcher.dispatch(messageToSend);
|
||||
}
|
||||
else if (this.logger.isWarnEnabled()) {
|
||||
this.logger.warn("MessageConverter returned null, no Message to dispatch");
|
||||
}
|
||||
messageToSend = (converted instanceof Message<?>) ? (Message<?>) converted
|
||||
: buildMessage(message, converted);
|
||||
this.dispatcher.dispatch(messageToSend);
|
||||
}
|
||||
catch (MessageDispatchingException e) {
|
||||
String exceptionMessage = e.getMessage() + " for amqp-channel '"
|
||||
|
||||
@@ -46,6 +46,7 @@ import org.springframework.integration.amqp.channel.PollableAmqpChannel;
|
||||
import org.springframework.integration.amqp.channel.PublishSubscribeAmqpChannel;
|
||||
import org.springframework.integration.amqp.support.AmqpHeaderMapper;
|
||||
import org.springframework.integration.amqp.support.DefaultAmqpHeaderMapper;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.support.ChannelInterceptor;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.interceptor.TransactionAttribute;
|
||||
@@ -152,7 +153,7 @@ public class AmqpChannelFactoryBean extends AbstractFactoryBean<AbstractAmqpChan
|
||||
|
||||
|
||||
@Override
|
||||
public void setBeanName(String name) {
|
||||
public void setBeanName(@Nullable String name) {
|
||||
this.beanName = name;
|
||||
}
|
||||
|
||||
@@ -399,8 +400,8 @@ public class AmqpChannelFactoryBean extends AbstractFactoryBean<AbstractAmqpChan
|
||||
this.channel.setInterceptors(this.interceptors);
|
||||
}
|
||||
this.channel.setBeanName(this.beanName);
|
||||
if (this.getBeanFactory() != null) {
|
||||
this.channel.setBeanFactory(this.getBeanFactory());
|
||||
if (getBeanFactory() != null) {
|
||||
this.channel.setBeanFactory(getBeanFactory()); // NOSONAR never null
|
||||
}
|
||||
if (this.defaultDeliveryMode != null) {
|
||||
this.channel.setDefaultDeliveryMode(this.defaultDeliveryMode);
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -126,7 +126,7 @@ public class MessagePublishingErrorHandler extends ErrorMessagePublisher impleme
|
||||
Message<?> failedMessage = (actualThrowable instanceof MessagingException) ?
|
||||
((MessagingException) actualThrowable).getFailedMessage() : null;
|
||||
if (getDefaultErrorChannel() == null && getChannelResolver() != null) {
|
||||
setChannel(getChannelResolver().resolveDestination(
|
||||
setChannel(getChannelResolver().resolveDestination(// NOSONAR not null
|
||||
IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME));
|
||||
}
|
||||
|
||||
@@ -137,11 +137,11 @@ public class MessagePublishingErrorHandler extends ErrorMessagePublisher impleme
|
||||
if (errorChannelHeader instanceof MessageChannel) {
|
||||
return (MessageChannel) errorChannelHeader;
|
||||
}
|
||||
Assert.isInstanceOf(String.class, errorChannelHeader,
|
||||
Assert.isInstanceOf(String.class, errorChannelHeader, () ->
|
||||
"Unsupported error channel header type. Expected MessageChannel or String, but actual type is [" +
|
||||
errorChannelHeader.getClass() + "]");
|
||||
errorChannelHeader.getClass() + "]"); // NOSONAR never null here
|
||||
if (getChannelResolver() != null) {
|
||||
return getChannelResolver().resolveDestination((String) errorChannelHeader);
|
||||
return getChannelResolver().resolveDestination((String) errorChannelHeader); // NOSONAR not null
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.integration.core.MessageSelector;
|
||||
import org.springframework.integration.support.management.QueueChannelManagement;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -116,19 +117,7 @@ public class QueueChannel extends AbstractPollableChannel implements QueueChanne
|
||||
return ((BlockingQueue<Message<?>>) this.queue).poll(timeout, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
else {
|
||||
Message<?> message = this.queue.poll();
|
||||
if (message == null) {
|
||||
long nanos = TimeUnit.MILLISECONDS.toNanos(timeout);
|
||||
long deadline = System.nanoTime() + nanos;
|
||||
while (message == null && nanos > 0) {
|
||||
this.queueSemaphore.tryAcquire(nanos, TimeUnit.NANOSECONDS); // NOSONAR ok to ignore result
|
||||
message = this.queue.poll();
|
||||
if (message == null) {
|
||||
nanos = deadline - System.nanoTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
return message;
|
||||
return pollNonBlockingQueue(timeout);
|
||||
}
|
||||
}
|
||||
if (timeout == 0) {
|
||||
@@ -141,7 +130,7 @@ public class QueueChannel extends AbstractPollableChannel implements QueueChanne
|
||||
else {
|
||||
Message<?> message = this.queue.poll();
|
||||
while (message == null) {
|
||||
this.queueSemaphore.tryAcquire(50, TimeUnit.MILLISECONDS);
|
||||
this.queueSemaphore.tryAcquire(50, TimeUnit.MILLISECONDS); // NOSONAR ok to ignore result
|
||||
message = this.queue.poll();
|
||||
}
|
||||
return message;
|
||||
@@ -153,6 +142,23 @@ public class QueueChannel extends AbstractPollableChannel implements QueueChanne
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Message<?> pollNonBlockingQueue(long timeout) throws InterruptedException {
|
||||
Message<?> message = this.queue.poll();
|
||||
if (message == null) {
|
||||
long nanos = TimeUnit.MILLISECONDS.toNanos(timeout);
|
||||
long deadline = System.nanoTime() + nanos;
|
||||
while (message == null && nanos > 0) {
|
||||
this.queueSemaphore.tryAcquire(nanos, TimeUnit.NANOSECONDS); // NOSONAR ok to ignore result
|
||||
message = this.queue.poll();
|
||||
if (message == null) {
|
||||
nanos = deadline - System.nanoTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Message<?>> clear() {
|
||||
List<Message<?>> clearedMessages = new ArrayList<>();
|
||||
|
||||
@@ -160,7 +160,7 @@ class DefaultConfiguringBeanFactoryPostProcessor
|
||||
else {
|
||||
nullChannelDefinition =
|
||||
((BeanDefinitionRegistry) this.beanFactory.getParentBeanFactory())
|
||||
.getBeanDefinition(IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME);
|
||||
.getBeanDefinition(IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME); // NOSONAR not null
|
||||
}
|
||||
if (!NullChannel.class.getName().equals(nullChannelDefinition.getBeanClassName())) {
|
||||
throw new IllegalStateException("The bean name '" + IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2014-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.
|
||||
@@ -38,6 +38,7 @@ import org.springframework.util.CollectionUtils;
|
||||
* {@link org.springframework.context.annotation.Bean} methods are also processed.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @since 4.0
|
||||
*/
|
||||
public class GlobalChannelInterceptorInitializer implements IntegrationConfigurationInitializer {
|
||||
@@ -50,14 +51,18 @@ public class GlobalChannelInterceptorInitializer implements IntegrationConfigura
|
||||
BeanDefinition beanDefinition = registry.getBeanDefinition(beanName);
|
||||
if (beanDefinition instanceof AnnotatedBeanDefinition) {
|
||||
AnnotationMetadata metadata = ((AnnotatedBeanDefinition) beanDefinition).getMetadata();
|
||||
Map<String, Object> annotationAttributes = metadata.getAnnotationAttributes(GlobalChannelInterceptor.class.getName());
|
||||
if (CollectionUtils.isEmpty(annotationAttributes) && beanDefinition.getSource() instanceof MethodMetadata) {
|
||||
Map<String, Object> annotationAttributes = metadata
|
||||
.getAnnotationAttributes(GlobalChannelInterceptor.class.getName());
|
||||
if (CollectionUtils.isEmpty(annotationAttributes)
|
||||
&& beanDefinition.getSource() instanceof MethodMetadata) {
|
||||
MethodMetadata beanMethod = (MethodMetadata) beanDefinition.getSource();
|
||||
annotationAttributes = beanMethod.getAnnotationAttributes(GlobalChannelInterceptor.class.getName());
|
||||
annotationAttributes =
|
||||
beanMethod.getAnnotationAttributes(GlobalChannelInterceptor.class.getName()); // NOSONAR not null
|
||||
}
|
||||
|
||||
if (!CollectionUtils.isEmpty(annotationAttributes)) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(GlobalChannelInterceptorWrapper.class)
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder
|
||||
.genericBeanDefinition(GlobalChannelInterceptorWrapper.class)
|
||||
.addConstructorArgReference(beanName)
|
||||
.addPropertyValue("patterns", annotationAttributes.get("patterns"))
|
||||
.addPropertyValue("order", annotationAttributes.get("order"));
|
||||
|
||||
@@ -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.
|
||||
@@ -48,6 +48,7 @@ public final class IdGeneratorConfigurer implements ApplicationListener<Applicat
|
||||
|
||||
private final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
@Override
|
||||
public synchronized void onApplicationEvent(ApplicationContextEvent event) {
|
||||
ApplicationContext context = event.getApplicationContext();
|
||||
if (event instanceof ContextRefreshedEvent) {
|
||||
@@ -75,7 +76,7 @@ public final class IdGeneratorConfigurer implements ApplicationListener<Applicat
|
||||
this.logger.debug("using custom MessageHeaders.IdGenerator [" + idGeneratorBean.getClass() + "]");
|
||||
}
|
||||
Field idGeneratorField = ReflectionUtils.findField(MessageHeaders.class, "idGenerator");
|
||||
ReflectionUtils.makeAccessible(idGeneratorField);
|
||||
ReflectionUtils.makeAccessible(idGeneratorField); // NOSONAR never null
|
||||
IdGenerator currentIdGenerator = (IdGenerator) ReflectionUtils.getField(idGeneratorField, null);
|
||||
if (currentIdGenerator != null) {
|
||||
if (currentIdGenerator.equals(idGeneratorBean)) {
|
||||
@@ -128,7 +129,7 @@ public final class IdGeneratorConfigurer implements ApplicationListener<Applicat
|
||||
private void unsetIdGenerator() {
|
||||
try {
|
||||
Field idGeneratorField = ReflectionUtils.findField(MessageHeaders.class, "idGenerator");
|
||||
ReflectionUtils.makeAccessible(idGeneratorField);
|
||||
ReflectionUtils.makeAccessible(idGeneratorField); // NOSONAR never null
|
||||
idGeneratorField.set(null, null);
|
||||
IdGeneratorConfigurer.theIdGenerator = null;
|
||||
}
|
||||
|
||||
@@ -79,8 +79,8 @@ public class IdempotentReceiverAutoProxyCreatorInitializer implements Integratio
|
||||
if (beanDefinition.getSource() instanceof MethodMetadata) {
|
||||
MethodMetadata beanMethod = (MethodMetadata) beanDefinition.getSource();
|
||||
String annotationType = IdempotentReceiver.class.getName();
|
||||
if (beanMethod.isAnnotated(annotationType)) {
|
||||
Object value = beanMethod.getAnnotationAttributes(annotationType).get("value");
|
||||
if (beanMethod.isAnnotated(annotationType)) { // NOSONAR never null
|
||||
Object value = beanMethod.getAnnotationAttributes(annotationType).get("value"); // NOSONAR
|
||||
if (value != null) {
|
||||
|
||||
Class<?> returnType;
|
||||
|
||||
@@ -54,7 +54,7 @@ public class IntegrationConverterInitializer implements IntegrationConfiguration
|
||||
|
||||
if (!hasIntegrationConverter && beanDefinition.getSource() instanceof MethodMetadata) {
|
||||
MethodMetadata beanMethod = (MethodMetadata) beanDefinition.getSource();
|
||||
hasIntegrationConverter = beanMethod.isAnnotated(IntegrationConverter.class.getName());
|
||||
hasIntegrationConverter = beanMethod.isAnnotated(IntegrationConverter.class.getName()); // NOSONAR never null
|
||||
}
|
||||
|
||||
if (hasIntegrationConverter) {
|
||||
|
||||
@@ -73,7 +73,7 @@ public class MessageHistoryRegistrar implements ImportBeanDefinitionRegistrar {
|
||||
if (propertyValue != null) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<Object> currentComponentNamePatternsSet = (Set<Object>) propertyValue.getValue();
|
||||
currentComponentNamePatternsSet.add(componentNamePatterns);
|
||||
currentComponentNamePatternsSet.add(componentNamePatterns); // NOSONAR never null
|
||||
}
|
||||
else {
|
||||
Set<Object> componentNamePatternsSet = new ManagedSet<Object>();
|
||||
|
||||
@@ -66,6 +66,7 @@ import org.springframework.integration.router.AbstractMessageRouter;
|
||||
import org.springframework.integration.scheduling.PollerMetadata;
|
||||
import org.springframework.integration.support.channel.BeanFactoryChannelResolver;
|
||||
import org.springframework.integration.util.MessagingAnnotationUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
@@ -195,7 +196,7 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
|
||||
if (AnnotatedElementUtils.isAnnotated(method, IdempotentReceiver.class.getName())
|
||||
&& !AnnotatedElementUtils.isAnnotated(method, Bean.class.getName())) {
|
||||
String[] interceptors = AnnotationUtils.getAnnotation(method, IdempotentReceiver.class).value();
|
||||
String[] interceptors = AnnotationUtils.getAnnotation(method, IdempotentReceiver.class).value(); // NOSONAR never null
|
||||
for (String interceptor : interceptors) {
|
||||
DefaultBeanFactoryPointcutAdvisor advisor = new DefaultBeanFactoryPointcutAdvisor();
|
||||
advisor.setAdviceBeanName(interceptor);
|
||||
@@ -469,7 +470,7 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
|
||||
protected String resolveTargetBeanName(Method method) {
|
||||
String id = method.getName();
|
||||
String[] names = AnnotationUtils.getAnnotation(method, Bean.class).name();
|
||||
String[] names = AnnotationUtils.getAnnotation(method, Bean.class).name(); // NOSONAR never null
|
||||
if (!ObjectUtils.isEmpty(names)) {
|
||||
id = names[0];
|
||||
}
|
||||
@@ -477,7 +478,7 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <H> H extractTypeIfPossible(Object targetObject, Class<H> expectedType) {
|
||||
protected <H> H extractTypeIfPossible(@Nullable Object targetObject, Class<H> expectedType) {
|
||||
if (targetObject == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -486,9 +487,6 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
}
|
||||
if (targetObject instanceof Advised) {
|
||||
TargetSource targetSource = ((Advised) targetObject).getTargetSource();
|
||||
if (targetSource == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return extractTypeIfPossible(targetSource.getTarget(), expectedType);
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -156,8 +156,8 @@ public abstract class AbstractConsumerEndpointParser extends AbstractBeanDefinit
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Collection<String> channelCandidateNames =
|
||||
(Collection<String>) caValues.getArgumentValue(0, Collection.class).getValue();
|
||||
channelCandidateNames.add(inputChannelName);
|
||||
(Collection<String>) caValues.getArgumentValue(0, Collection.class).getValue(); // NOSONAR see comment above
|
||||
channelCandidateNames.add(inputChannelName); // NOSONAR
|
||||
}
|
||||
else {
|
||||
parserContext.getReaderContext().error("Failed to locate '" +
|
||||
|
||||
@@ -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.
|
||||
@@ -49,6 +49,7 @@ import org.springframework.util.xml.DomUtils;
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Artem Bilan
|
||||
* @author Gunnar Hillert
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public class ChainParser extends AbstractConsumerEndpointParser {
|
||||
|
||||
@@ -147,7 +148,7 @@ public class ChainParser extends AbstractConsumerEndpointParser {
|
||||
}
|
||||
}
|
||||
|
||||
holder.getBeanDefinition().getPropertyValues().add("componentName", handlerComponentName);
|
||||
holder.getBeanDefinition().getPropertyValues().add("componentName", handlerComponentName); // NOSONAR never null
|
||||
|
||||
if (hasId) {
|
||||
BeanDefinitionReaderUtils.registerBeanDefinition(holder, parserContext.getRegistry());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 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.
|
||||
@@ -36,6 +36,7 @@ import org.springframework.beans.factory.xml.ParserContext;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public class ChannelInterceptorParser {
|
||||
|
||||
@@ -60,7 +61,7 @@ public class ChannelInterceptorParser {
|
||||
if ("bean".equals(localName)) {
|
||||
BeanDefinitionParserDelegate delegate = parserContext.getDelegate();
|
||||
BeanDefinitionHolder holder = delegate.parseBeanDefinitionElement(childElement);
|
||||
holder = delegate.decorateBeanDefinitionIfRequired(childElement, holder);
|
||||
holder = delegate.decorateBeanDefinitionIfRequired(childElement, holder); // NOSONAR never null
|
||||
parserContext.registerBeanComponent(new BeanComponentDefinition(holder));
|
||||
interceptors.add(new RuntimeBeanReference(holder.getBeanName()));
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -97,7 +97,8 @@ public class GlobalChannelInterceptorParser extends AbstractBeanDefinitionParser
|
||||
}
|
||||
else {
|
||||
BeanDefinition beanDef = delegate.parseCustomElement(child);
|
||||
beanName = BeanDefinitionReaderUtils.generateBeanName(beanDef, parserContext.getRegistry());
|
||||
beanName = BeanDefinitionReaderUtils.generateBeanName(beanDef, // NOSONAR never null
|
||||
parserContext.getRegistry());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -28,6 +28,7 @@ import org.springframework.beans.factory.xml.ParserContext;
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 2.1
|
||||
*
|
||||
@@ -50,7 +51,7 @@ public class GlobalWireTapParser extends GlobalChannelInterceptorParser {
|
||||
.iterator()
|
||||
.next()
|
||||
.getValue();
|
||||
return wireTapBean.getBeanName() + ".globalChannelInterceptor";
|
||||
return wireTapBean.getBeanName() + ".globalChannelInterceptor"; // NOSONAR never null
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -209,7 +209,7 @@ public abstract class HeaderEnricherParserSupport extends AbstractTransformerPar
|
||||
if (beanElement != null) {
|
||||
innerComponentDefinition = parserContext.getDelegate()
|
||||
.parseBeanDefinitionElement(beanElement)
|
||||
.getBeanDefinition();
|
||||
.getBeanDefinition(); // NOSONAR never null
|
||||
}
|
||||
else if (isScript) {
|
||||
innerComponentDefinition = parserContext.getDelegate().parseCustomElement(scriptElement);
|
||||
|
||||
@@ -318,7 +318,7 @@ public abstract class IntegrationNamespaceUtils {
|
||||
Element beanElement = childElements.get(0);
|
||||
BeanDefinitionParserDelegate delegate = parserContext.getDelegate();
|
||||
BeanDefinitionHolder bdHolder = delegate.parseBeanDefinitionElement(beanElement);
|
||||
bdHolder = delegate.decorateBeanDefinitionIfRequired(beanElement, bdHolder);
|
||||
bdHolder = delegate.decorateBeanDefinitionIfRequired(beanElement, bdHolder); // NOSONAR never null
|
||||
BeanDefinition inDef = bdHolder.getBeanDefinition();
|
||||
innerComponentDefinition = new BeanComponentDefinition(inDef, bdHolder.getBeanName());
|
||||
}
|
||||
@@ -514,7 +514,7 @@ public abstract class IntegrationNamespaceUtils {
|
||||
if ("bean".equals(localName)) {
|
||||
BeanDefinitionHolder holder = parserContext.getDelegate().parseBeanDefinitionElement(
|
||||
childElement, parentBeanDefinition);
|
||||
parserContext.registerBeanComponent(new BeanComponentDefinition(holder));
|
||||
parserContext.registerBeanComponent(new BeanComponentDefinition(holder)); // NOSONAR never null
|
||||
adviceChain.add(new RuntimeBeanReference(holder.getBeanName()));
|
||||
}
|
||||
else if ("ref".equals(localName)) {
|
||||
@@ -636,7 +636,7 @@ public abstract class IntegrationNamespaceUtils {
|
||||
else {
|
||||
candidates = (ManagedMap<String, String>) argumentValue.getValue();
|
||||
}
|
||||
candidates.put(handlerBeanName, channelName);
|
||||
candidates.put(handlerBeanName, channelName); // NOSONAR never null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
* Copyright 2014-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.
|
||||
@@ -36,6 +36,7 @@ import org.springframework.util.xml.DomUtils;
|
||||
* Parser for the <scatter-gather> element.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @since 4.1
|
||||
*/
|
||||
public class ScatterGatherParser extends AbstractConsumerEndpointParser {
|
||||
@@ -85,7 +86,7 @@ public class ScatterGatherParser extends AbstractConsumerEndpointParser {
|
||||
if (hasScatterer && scatterer.hasAttribute(ID_ATTRIBUTE)) {
|
||||
scattererId = scatterer.getAttribute(ID_ATTRIBUTE);
|
||||
}
|
||||
parserContext.getRegistry().registerBeanDefinition(scattererId, scattererDefinition);
|
||||
parserContext.getRegistry().registerBeanDefinition(scattererId, scattererDefinition); // NOSONAR not null
|
||||
builder.addConstructorArgValue(new RuntimeBeanReference(scattererId));
|
||||
}
|
||||
|
||||
@@ -108,7 +109,7 @@ public class ScatterGatherParser extends AbstractConsumerEndpointParser {
|
||||
if (gatherer != null && gatherer.hasAttribute(ID_ATTRIBUTE)) {
|
||||
gathererId = gatherer.getAttribute(ID_ATTRIBUTE);
|
||||
}
|
||||
parserContext.getRegistry().registerBeanDefinition(gathererId, gathererDefinition);
|
||||
parserContext.getRegistry().registerBeanDefinition(gathererId, gathererDefinition); // NOSONAR not null
|
||||
builder.addConstructorArgValue(new RuntimeBeanReference(gathererId));
|
||||
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "gather-channel");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -37,6 +37,7 @@ import org.springframework.util.StringUtils;
|
||||
* Parser for the <spel-property-accessors> element.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @since 3.0
|
||||
*/
|
||||
public class SpelPropertyAccessorsParser implements BeanDefinitionParser {
|
||||
@@ -70,7 +71,7 @@ public class SpelPropertyAccessorsParser implements BeanDefinitionParser {
|
||||
}
|
||||
else if (delegate.nodeNameEquals(ele, BeanDefinitionParserDelegate.REF_ELEMENT)) {
|
||||
BeanReference propertyAccessorRef = (BeanReference) delegate.parsePropertySubElement(ele, null);
|
||||
propertyAccessorName = propertyAccessorRef.getBeanName();
|
||||
propertyAccessorName = propertyAccessorRef.getBeanName(); // NOSONAR not null
|
||||
propertyAccessor = propertyAccessorRef;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -297,9 +297,6 @@ public abstract class IntegrationObjectSupport implements BeanNameAware, NamedCo
|
||||
}
|
||||
if (targetObject instanceof Advised) {
|
||||
TargetSource targetSource = ((Advised) targetObject).getTargetSource();
|
||||
if (targetSource == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return extractTypeIfPossible(targetSource.getTarget(), expectedType);
|
||||
}
|
||||
|
||||
@@ -181,9 +181,10 @@ public class ErrorMessagePublisher implements BeanFactoryAware {
|
||||
lastThrowable = payloadWhenNull(context);
|
||||
}
|
||||
else if (!(lastThrowable instanceof MessagingException)) {
|
||||
lastThrowable = new MessagingException(
|
||||
(Message<?>) context.getAttribute(ErrorMessageUtils.FAILED_MESSAGE_CONTEXT_KEY),
|
||||
lastThrowable.getMessage(), lastThrowable);
|
||||
Message<?> message = (Message<?>) context.getAttribute(ErrorMessageUtils.FAILED_MESSAGE_CONTEXT_KEY);
|
||||
lastThrowable = message == null
|
||||
? new MessagingException(lastThrowable.getMessage(), lastThrowable)
|
||||
: new MessagingException(message, lastThrowable.getMessage(), lastThrowable);
|
||||
}
|
||||
return lastThrowable;
|
||||
}
|
||||
@@ -196,8 +197,10 @@ public class ErrorMessagePublisher implements BeanFactoryAware {
|
||||
* @see ErrorMessageUtils
|
||||
*/
|
||||
protected Throwable payloadWhenNull(AttributeAccessor context) {
|
||||
return new MessagingException((Message<?>) context.getAttribute(ErrorMessageUtils.FAILED_MESSAGE_CONTEXT_KEY),
|
||||
"No root cause exception available");
|
||||
Message<?> message = (Message<?>) context.getAttribute(ErrorMessageUtils.FAILED_MESSAGE_CONTEXT_KEY);
|
||||
return message == null
|
||||
? new MessagingException("No root cause exception available")
|
||||
: new MessagingException(message, "No root cause exception available");
|
||||
}
|
||||
|
||||
private void populateChannel() {
|
||||
|
||||
@@ -333,7 +333,9 @@ public final class IntegrationFlows {
|
||||
GatewayProxyFactoryBean gatewayProxyFactoryBean = new AnnotationGatewayProxyFactoryBean(serviceInterface);
|
||||
|
||||
gatewayProxyFactoryBean.setDefaultRequestChannel(gatewayRequestChannel);
|
||||
gatewayProxyFactoryBean.setBeanName(beanName);
|
||||
if (beanName != null) {
|
||||
gatewayProxyFactoryBean.setBeanName(beanName);
|
||||
}
|
||||
|
||||
return from(gatewayRequestChannel)
|
||||
.addComponent(gatewayProxyFactoryBean);
|
||||
@@ -353,6 +355,7 @@ public final class IntegrationFlows {
|
||||
|
||||
private static IntegrationFlowBuilder from(MessagingGatewaySupport inboundGateway,
|
||||
IntegrationFlowBuilder integrationFlowBuilder) {
|
||||
|
||||
MessageChannel outputChannel = inboundGateway.getRequestChannel();
|
||||
if (outputChannel == null) {
|
||||
outputChannel = new DirectChannel();
|
||||
|
||||
@@ -351,8 +351,8 @@ public class IntegrationFlowBeanPostProcessor
|
||||
if (bean instanceof BeanNameAware) {
|
||||
((BeanNameAware) bean).setBeanName(beanName);
|
||||
}
|
||||
if (bean instanceof BeanClassLoaderAware) {
|
||||
((BeanClassLoaderAware) bean).setBeanClassLoader(this.beanFactory.getBeanClassLoader());
|
||||
if (bean instanceof BeanClassLoaderAware && this.beanFactory.getBeanClassLoader() != null) {
|
||||
((BeanClassLoaderAware) bean).setBeanClassLoader(this.beanFactory.getBeanClassLoader()); // NOSONAR
|
||||
}
|
||||
if (bean instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware) bean).setBeanFactory(this.beanFactory);
|
||||
|
||||
@@ -268,9 +268,6 @@ public class SourcePollingChannelAdapter extends AbstractPollingEndpoint
|
||||
return target;
|
||||
}
|
||||
Advised advised = (Advised) target;
|
||||
if (advised.getTargetSource() == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return extractProxyTarget(advised.getTargetSource().getTarget());
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.stream.Collectors;
|
||||
import org.springframework.expression.EvaluationContext;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.common.LiteralExpression;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -61,6 +62,7 @@ import org.springframework.util.Assert;
|
||||
* </p>
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
@@ -192,6 +194,7 @@ public final class ExpressionEvalMap extends AbstractMap<String, Object> {
|
||||
@FunctionalInterface
|
||||
public interface EvaluationCallback {
|
||||
|
||||
@Nullable
|
||||
Object evaluate(Expression expression);
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -19,16 +19,20 @@ package org.springframework.integration.expression;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Strategy interface for retrieving Expressions.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ExpressionSource {
|
||||
|
||||
@Nullable
|
||||
Expression getExpression(String key, Locale locale);
|
||||
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
import org.springframework.expression.spel.support.StandardTypeConverter;
|
||||
import org.springframework.integration.context.IntegrationContextUtils;
|
||||
import org.springframework.integration.support.utils.IntegrationUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -163,10 +164,12 @@ public final class ExpressionUtils {
|
||||
* @return the File.
|
||||
* @since 5.0
|
||||
*/
|
||||
public static File expressionToFile(Expression expression, EvaluationContext evaluationContext, Message<?> message,
|
||||
String name) {
|
||||
public static File expressionToFile(Expression expression, EvaluationContext evaluationContext,
|
||||
@Nullable Message<?> message, String name) {
|
||||
File file;
|
||||
Object value = expression.getValue(evaluationContext, message);
|
||||
Object value = message == null
|
||||
? expression.getValue(evaluationContext)
|
||||
: expression.getValue(evaluationContext, message);
|
||||
if (value == null) {
|
||||
throw new IllegalStateException(String.format("The provided %s expression (%s) must not evaluate to null.",
|
||||
name, expression.getExpressionString()));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-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.
|
||||
@@ -87,7 +87,8 @@ public class FunctionExpression<S> implements Expression {
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext context) throws EvaluationException {
|
||||
return getValue(context.getRootObject().getValue());
|
||||
Object root = context.getRootObject().getValue();
|
||||
return root == null ? getValue() : getValue(root);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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.
|
||||
@@ -19,6 +19,7 @@ package org.springframework.integration.expression;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -37,6 +38,7 @@ import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.ExpressionParser;
|
||||
import org.springframework.expression.spel.SpelParserConfiguration;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.DefaultPropertiesPersister;
|
||||
import org.springframework.util.PropertiesPersister;
|
||||
@@ -240,13 +242,14 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
|
||||
*/
|
||||
@Override
|
||||
public Expression getExpression(String key, Locale locale) {
|
||||
String expressionString = this.getExpressionString(key, locale);
|
||||
String expressionString = getExpressionString(key, locale);
|
||||
if (expressionString != null) {
|
||||
return this.parser.parseExpression(expressionString);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getExpressionString(String key, Locale locale) {
|
||||
if (this.cacheMillis < 0) {
|
||||
PropertiesHolder propHolder = getMergedProperties(locale);
|
||||
@@ -476,32 +479,15 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
|
||||
InputStream is = resource.getInputStream();
|
||||
Properties props = new Properties();
|
||||
try {
|
||||
if (resource.getFilename().endsWith(XML_SUFFIX)) {
|
||||
String resourceFilename = resource.getFilename();
|
||||
if (resourceFilename != null && resourceFilename.endsWith(XML_SUFFIX)) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Loading properties [" + resource.getFilename() + "]");
|
||||
logger.debug("Loading properties [" + resourceFilename + "]");
|
||||
}
|
||||
this.propertiesPersister.loadFromXml(props, is);
|
||||
}
|
||||
else {
|
||||
String encoding = null;
|
||||
if (this.fileEncodings != null) {
|
||||
encoding = this.fileEncodings.getProperty(filename);
|
||||
}
|
||||
if (encoding == null) {
|
||||
encoding = this.defaultEncoding;
|
||||
}
|
||||
if (encoding != null) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Loading properties [" + resource.getFilename() + "] with encoding '" + encoding + "'");
|
||||
}
|
||||
this.propertiesPersister.load(props, new InputStreamReader(is, encoding));
|
||||
}
|
||||
else {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Loading properties [" + resource.getFilename() + "]");
|
||||
}
|
||||
this.propertiesPersister.load(props, is);
|
||||
}
|
||||
loadFromProperties(resource, filename, is, props, resourceFilename);
|
||||
}
|
||||
return props;
|
||||
}
|
||||
@@ -510,6 +496,32 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
|
||||
}
|
||||
}
|
||||
|
||||
private void loadFromProperties(Resource resource, String filename, InputStream is, Properties props,
|
||||
String resourceFilename) throws IOException, UnsupportedEncodingException {
|
||||
String encoding = null;
|
||||
if (this.fileEncodings != null) {
|
||||
encoding = this.fileEncodings.getProperty(filename);
|
||||
}
|
||||
if (encoding == null) {
|
||||
encoding = this.defaultEncoding;
|
||||
}
|
||||
if (encoding != null) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Loading properties ["
|
||||
+ (resourceFilename == null ? resource : resourceFilename)
|
||||
+ "] with encoding '" + encoding + "'");
|
||||
}
|
||||
this.propertiesPersister.load(props, new InputStreamReader(is, encoding));
|
||||
}
|
||||
else {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Loading properties [" + (resourceFilename == null ? resource : resourceFilename)
|
||||
+ "]");
|
||||
}
|
||||
this.propertiesPersister.load(props, is);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear the resource bundle cache.
|
||||
@@ -570,6 +582,7 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
|
||||
return this.refreshTimestamp;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getProperty(String code) {
|
||||
if (this.properties == null) {
|
||||
return null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-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.
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.integration.expression;
|
||||
|
||||
import org.boon.core.Supplier;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.expression.EvaluationContext;
|
||||
@@ -86,7 +86,8 @@ public class SupplierExpression<T> implements Expression {
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext context) throws EvaluationException {
|
||||
return getValue(context.getRootObject().getValue());
|
||||
Object root = context.getRootObject().getValue();
|
||||
return root == null ? getValue() : getValue(root);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/**
|
||||
* Provides classes supporting SpEL expressions.
|
||||
*/
|
||||
@org.springframework.lang.NonNullApi
|
||||
package org.springframework.integration.expression;
|
||||
|
||||
@@ -58,7 +58,7 @@ public class AnnotationGatewayProxyFactoryBean extends GatewayProxyFactoryBean {
|
||||
this.gatewayAttributes = gatewayAttributes;
|
||||
|
||||
String id = gatewayAttributes.getString("name");
|
||||
if (!StringUtils.hasText(id)) {
|
||||
if (StringUtils.hasText(id)) {
|
||||
setBeanName(id);
|
||||
}
|
||||
}
|
||||
@@ -88,11 +88,15 @@ public class AnnotationGatewayProxyFactoryBean extends GatewayProxyFactoryBean {
|
||||
|
||||
String defaultRequestChannel =
|
||||
beanFactory.resolveEmbeddedValue(this.gatewayAttributes.getString("defaultRequestChannel"));
|
||||
setDefaultRequestChannelName(defaultRequestChannel);
|
||||
if (StringUtils.hasText(defaultRequestChannel)) {
|
||||
setDefaultRequestChannelName(defaultRequestChannel);
|
||||
}
|
||||
|
||||
String defaultReplyChannel =
|
||||
beanFactory.resolveEmbeddedValue(this.gatewayAttributes.getString("defaultReplyChannel"));
|
||||
setDefaultReplyChannelName(defaultReplyChannel);
|
||||
if (StringUtils.hasText(defaultReplyChannel)) {
|
||||
setDefaultReplyChannelName(defaultReplyChannel);
|
||||
}
|
||||
|
||||
String errorChannel = beanFactory.resolveEmbeddedValue(this.gatewayAttributes.getString("errorChannel"));
|
||||
setErrorChannelName(errorChannel);
|
||||
|
||||
@@ -360,6 +360,7 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
* @return the channel.
|
||||
* @since 4.2
|
||||
*/
|
||||
@Nullable
|
||||
public MessageChannel getRequestChannel() {
|
||||
if (this.requestChannelName != null) {
|
||||
synchronized (this) {
|
||||
|
||||
@@ -352,7 +352,9 @@ public class IntegrationGraphServer implements ApplicationContextAware, Applicat
|
||||
|
||||
private MessageGatewayNode gatewayNode(String name, MessagingGatewaySupport gateway) {
|
||||
String errorChannel = gateway.getErrorChannel() != null ? gateway.getErrorChannel().toString() : null;
|
||||
String requestChannel = gateway.getRequestChannel() != null ? gateway.getRequestChannel().toString() : null;
|
||||
String requestChannel = gateway.getRequestChannel() != null
|
||||
? gateway.getRequestChannel().toString() // NOSONAR not null
|
||||
: null;
|
||||
return new MessageGatewayNode(this.nodeId.incrementAndGet(), name, gateway,
|
||||
requestChannel, errorChannel);
|
||||
}
|
||||
|
||||
@@ -137,14 +137,12 @@ public abstract class AbstractMessageRouter extends AbstractMessageHandler imple
|
||||
}
|
||||
|
||||
protected ConversionService getRequiredConversionService() {
|
||||
if (this.getConversionService() == null) {
|
||||
synchronized (this) {
|
||||
if (getConversionService() == null) {
|
||||
setConversionService(DefaultConversionService.getSharedInstance());
|
||||
}
|
||||
}
|
||||
ConversionService conversionService = getConversionService();
|
||||
if (conversionService == null) {
|
||||
conversionService = DefaultConversionService.getSharedInstance();
|
||||
setConversionService(conversionService);
|
||||
}
|
||||
return getConversionService();
|
||||
return conversionService;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -349,6 +349,7 @@ public class MessageGroupQueue extends AbstractQueue<Message<?>> implements Bloc
|
||||
/**
|
||||
* It is assumed that the 'storeLock' is being held by the caller, otherwise
|
||||
* IllegalMonitorStateException may be thrown
|
||||
* @return a message // TODO @Nullable
|
||||
*/
|
||||
protected Message<?> doPoll() {
|
||||
Message<?> message = this.messageGroupStore.pollMessageFromGroup(this.groupId);
|
||||
@@ -360,6 +361,7 @@ public class MessageGroupQueue extends AbstractQueue<Message<?>> implements Bloc
|
||||
* It is assumed that the 'storeLock' is being held by the caller, otherwise
|
||||
* IllegalMonitorStateException may be thrown
|
||||
* @param message the message to offer.
|
||||
* @return true if offered.
|
||||
*/
|
||||
protected boolean doOffer(Message<?> message) {
|
||||
boolean offered = false;
|
||||
|
||||
@@ -448,9 +448,8 @@ public class FileWritingMessageHandler extends AbstractReplyProducingMessageHand
|
||||
this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory());
|
||||
|
||||
if (this.destinationDirectoryExpression instanceof LiteralExpression) {
|
||||
final File directory =
|
||||
new File(this.destinationDirectoryExpression.getValue(this.evaluationContext, String.class));
|
||||
|
||||
final File directory = ExpressionUtils.expressionToFile(this.destinationDirectoryExpression,
|
||||
this.evaluationContext, null, "destinationDirectoryExpression");
|
||||
validateDestinationDirectory(directory, this.autoCreateDirectory);
|
||||
}
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ public class FileTailInboundChannelAdapterFactoryBean extends AbstractFactoryBea
|
||||
adapter.setApplicationEventPublisher(this.applicationEventPublisher);
|
||||
}
|
||||
if (getBeanFactory() != null) {
|
||||
adapter.setBeanFactory(getBeanFactory());
|
||||
adapter.setBeanFactory(getBeanFactory()); // NOSONAR never null
|
||||
}
|
||||
adapter.afterPropertiesSet();
|
||||
this.adapter = adapter;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017 the original author or authors.
|
||||
* Copyright 2017-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.
|
||||
@@ -30,6 +30,7 @@ import org.springframework.util.Assert;
|
||||
* A SpEL expression based {@link AbstractFileListFilter} implementation.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
@@ -61,7 +62,8 @@ public class ExpressionFileListFilter<F> extends AbstractFileListFilter<F>
|
||||
|
||||
@Override
|
||||
public boolean accept(F file) {
|
||||
return this.expression.getValue(getEvaluationContext(), file, Boolean.class);
|
||||
Boolean pass = this.expression.getValue(getEvaluationContext(), file, Boolean.class);
|
||||
return pass == null ? false : pass;
|
||||
}
|
||||
|
||||
private EvaluationContext getEvaluationContext() {
|
||||
|
||||
@@ -536,7 +536,9 @@ public abstract class AbstractRemoteFileOutboundGateway<F> extends AbstractReply
|
||||
|| Command.MGET.equals(this.command)) {
|
||||
Assert.notNull(this.localDirectoryExpression, "localDirectory must not be null");
|
||||
if (this.localDirectoryExpression instanceof ValueExpression) {
|
||||
File localDirectory = this.localDirectoryExpression.getValue(File.class);
|
||||
File localDirectory = ExpressionUtils.expressionToFile(this.localDirectoryExpression,
|
||||
ExpressionUtils.createStandardEvaluationContext(getBeanFactory()), null,
|
||||
"localDirectoryExpression");
|
||||
try {
|
||||
if (!localDirectory.exists()) {
|
||||
if (this.autoCreateLocalDirectory) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-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.
|
||||
@@ -54,7 +54,7 @@ public class FtpOutboundChannelAdapterParser extends RemoteFileOutboundChannelAd
|
||||
.iterator()
|
||||
.next()
|
||||
.getValue();
|
||||
templateDefinition.getPropertyValues()
|
||||
templateDefinition.getPropertyValues() // NOSONAR never null
|
||||
.add("existsMode", FtpRemoteFileTemplate.ExistsMode.NLST);
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -66,7 +66,7 @@ public class FtpOutboundGatewayParser extends AbstractRemoteFileOutboundGatewayP
|
||||
.iterator()
|
||||
.next()
|
||||
.getValue();
|
||||
templateDefinition.getPropertyValues()
|
||||
templateDefinition.getPropertyValues() // NOSONAR never null
|
||||
.add("existsMode", FtpRemoteFileTemplate.ExistsMode.NLST);
|
||||
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "working-dir-expression",
|
||||
|
||||
@@ -217,7 +217,7 @@ public class FtpTests extends FtpTestSupport {
|
||||
assertNotNull(result);
|
||||
List<File> localFiles = (List<File>) result.getPayload();
|
||||
// should have filtered ftpSource2.txt
|
||||
assertEquals(2, localFiles.size());
|
||||
assertEquals("unexpected local files " + localFiles, 2, localFiles.size());
|
||||
|
||||
for (File file : localFiles) {
|
||||
assertThat(file.getPath().replaceAll(Matcher.quoteReplacement(File.separator), "/"),
|
||||
|
||||
Reference in New Issue
Block a user