Core Sonar fixes
* Polishing according PR comments
This commit is contained in:
committed by
Artem Bilan
parent
fc18476fc1
commit
2b1976ce6f
@@ -69,7 +69,7 @@ public class IntegrationMessageHeaderAccessor extends MessageHeaderAccessor {
|
||||
|
||||
private Set<String> readOnlyHeaders = new HashSet<>();
|
||||
|
||||
public IntegrationMessageHeaderAccessor(Message<?> message) {
|
||||
public IntegrationMessageHeaderAccessor(@Nullable Message<?> message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2017 the original author or authors.
|
||||
* Copyright 2015-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.
|
||||
@@ -24,6 +24,7 @@ import java.util.concurrent.Executor;
|
||||
|
||||
import org.springframework.integration.dispatcher.AbstractDispatcher;
|
||||
import org.springframework.integration.support.MessagingExceptionWrapper;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageDeliveryException;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
@@ -60,7 +61,7 @@ public abstract class AbstractExecutorChannel extends AbstractSubscribableChanne
|
||||
|
||||
protected volatile int executorInterceptorsSize;
|
||||
|
||||
public AbstractExecutorChannel(Executor executor) {
|
||||
public AbstractExecutorChannel(@Nullable Executor executor) {
|
||||
this.executor = executor;
|
||||
}
|
||||
|
||||
@@ -171,6 +172,7 @@ public abstract class AbstractExecutorChannel extends AbstractSubscribableChanne
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Message<?> applyBeforeHandle(Message<?> message, Deque<ExecutorChannelInterceptor> interceptorStack) {
|
||||
Message<?> theMessage = message;
|
||||
for (ChannelInterceptor interceptor : AbstractExecutorChannel.this.interceptors.interceptors) {
|
||||
|
||||
@@ -554,7 +554,7 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport
|
||||
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
this.meters.forEach(t -> t.remove());
|
||||
this.meters.forEach(MeterFacade::remove);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -566,7 +566,7 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport
|
||||
|
||||
protected final List<ChannelInterceptor> interceptors = new CopyOnWriteArrayList<ChannelInterceptor>();
|
||||
|
||||
private volatile int size;
|
||||
private int size;
|
||||
|
||||
public ChannelInterceptorList(Log logger) {
|
||||
this.logger = logger;
|
||||
@@ -594,17 +594,19 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport
|
||||
this.interceptors.add(index, interceptor);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Message<?> preSend(Message<?> message, MessageChannel channel,
|
||||
Deque<ChannelInterceptor> interceptorStack) {
|
||||
if (this.size > 0) {
|
||||
for (ChannelInterceptor interceptor : this.interceptors) {
|
||||
Message<?> previous = message;
|
||||
message = interceptor.preSend(message, channel);
|
||||
if (message == null) {
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug(interceptor.getClass().getSimpleName()
|
||||
+ " returned null from preSend, i.e. precluding the send.");
|
||||
}
|
||||
afterSendCompletion(null, channel, false, null, interceptorStack);
|
||||
afterSendCompletion(previous, channel, false, null, interceptorStack);
|
||||
return null;
|
||||
}
|
||||
interceptorStack.add(interceptor);
|
||||
@@ -648,6 +650,7 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Message<?> postReceive(Message<?> message, MessageChannel channel) {
|
||||
if (this.size > 0) {
|
||||
for (ChannelInterceptor interceptor : this.interceptors) {
|
||||
@@ -688,6 +691,7 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ChannelInterceptor remove(int index) {
|
||||
ChannelInterceptor removed = this.interceptors.remove(index);
|
||||
if (removed != null) {
|
||||
|
||||
@@ -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.
|
||||
@@ -20,6 +20,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.integration.core.MessageSelector;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -38,6 +39,7 @@ import org.springframework.util.Assert;
|
||||
* place. Such messages will not be included in the returned list.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public class ChannelPurger {
|
||||
|
||||
@@ -50,7 +52,7 @@ public class ChannelPurger {
|
||||
this(null, channels);
|
||||
}
|
||||
|
||||
public ChannelPurger(MessageSelector selector, QueueChannel... channels) {
|
||||
public ChannelPurger(@Nullable MessageSelector selector, QueueChannel... channels) {
|
||||
Assert.notEmpty(channels, "at least one channel is required");
|
||||
if (channels.length == 1) {
|
||||
Assert.notNull(channels[0], "channel must not be null");
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.springframework.integration.IntegrationMessageHeaderAccessor;
|
||||
import org.springframework.integration.store.MessageGroupQueue;
|
||||
import org.springframework.integration.store.PriorityCapableChannelMessageStore;
|
||||
import org.springframework.integration.util.UpperBound;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
|
||||
@@ -84,7 +85,7 @@ public class PriorityChannel extends QueueChannel {
|
||||
* @param capacity The capacity.
|
||||
* @param comparator The comparator.
|
||||
*/
|
||||
public PriorityChannel(int capacity, Comparator<Message<?>> comparator) {
|
||||
public PriorityChannel(int capacity, @Nullable Comparator<Message<?>> comparator) {
|
||||
super(new PriorityBlockingQueue<>(11, new SequenceFallbackComparator(comparator)));
|
||||
this.upperBound = new UpperBound(capacity);
|
||||
this.useMessageStore = false;
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.springframework.integration.context.IntegrationProperties;
|
||||
import org.springframework.integration.dispatcher.BroadcastingDispatcher;
|
||||
import org.springframework.integration.support.channel.BeanFactoryChannelResolver;
|
||||
import org.springframework.integration.util.ErrorHandlingTaskExecutor;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ErrorHandler;
|
||||
|
||||
@@ -49,7 +50,7 @@ public class PublishSubscribeChannel extends AbstractExecutorChannel {
|
||||
* the message sender's thread.
|
||||
* @param executor The executor.
|
||||
*/
|
||||
public PublishSubscribeChannel(Executor executor) {
|
||||
public PublishSubscribeChannel(@Nullable Executor executor) {
|
||||
super(executor);
|
||||
this.dispatcher = new BroadcastingDispatcher(executor);
|
||||
}
|
||||
|
||||
@@ -98,9 +98,11 @@ public class ScatterGatherParser extends AbstractConsumerEndpointParser {
|
||||
}
|
||||
catch (ParserConfigurationException e) {
|
||||
parserContext.getReaderContext().error(e.getMessage(), element);
|
||||
// NOSONAR below to prevent a false positive in SONAR for a null gatherer
|
||||
}
|
||||
}
|
||||
gathererDefinition = GATHERER_PARSER.parse(gatherer, new ParserContext(parserContext.getReaderContext(),
|
||||
gathererDefinition = GATHERER_PARSER.parse(gatherer, // NOSONAR
|
||||
new ParserContext(parserContext.getReaderContext(),
|
||||
parserContext.getDelegate(), scatterGatherDefinition));
|
||||
String gathererId = id + ".gatherer";
|
||||
if (gatherer != null && gatherer.hasAttribute(ID_ATTRIBUTE)) {
|
||||
|
||||
@@ -227,11 +227,7 @@ public abstract class IntegrationObjectSupport implements BeanNameAware, NamedCo
|
||||
|
||||
public ConversionService getConversionService() {
|
||||
if (this.conversionService == null && this.beanFactory != null) {
|
||||
synchronized (this) {
|
||||
if (this.conversionService == null) {
|
||||
this.conversionService = IntegrationUtils.getConversionService(this.beanFactory);
|
||||
}
|
||||
}
|
||||
this.conversionService = IntegrationUtils.getConversionService(this.beanFactory);
|
||||
if (this.conversionService == null && this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Unable to attempt conversion of Message payload types. Component '" +
|
||||
this.getComponentName() + "' has no explicit ConversionService reference, " +
|
||||
|
||||
@@ -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.
|
||||
@@ -27,6 +27,7 @@ import org.springframework.integration.support.DefaultErrorMessageStrategy;
|
||||
import org.springframework.integration.support.ErrorMessageStrategy;
|
||||
import org.springframework.integration.support.ErrorMessageUtils;
|
||||
import org.springframework.integration.support.channel.BeanFactoryChannelResolver;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
@@ -144,7 +145,7 @@ public class ErrorMessagePublisher implements BeanFactoryAware {
|
||||
* @param failedMessage the message.
|
||||
* @param throwable the throwable.
|
||||
*/
|
||||
public void publish(Message<?> inputMessage, Message<?> failedMessage, Throwable throwable) {
|
||||
public void publish(@Nullable Message<?> inputMessage, Message<?> failedMessage, Throwable throwable) {
|
||||
publish(throwable, ErrorMessageUtils.getAttributeAccessor(inputMessage, failedMessage));
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
|
||||
import org.springframework.integration.gateway.AnnotationGatewayProxyFactoryBean;
|
||||
import org.springframework.integration.gateway.GatewayProxyFactoryBean;
|
||||
import org.springframework.integration.gateway.MessagingGatewaySupport;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -326,7 +327,7 @@ public final class IntegrationFlows {
|
||||
* @param beanName the bean name to be used for registering bean for the gateway proxy
|
||||
* @return new {@link IntegrationFlowBuilder}.
|
||||
*/
|
||||
public static IntegrationFlowBuilder from(Class<?> serviceInterface, String beanName) {
|
||||
public static IntegrationFlowBuilder from(Class<?> serviceInterface, @Nullable String beanName) {
|
||||
final DirectChannel gatewayRequestChannel = new DirectChannel();
|
||||
|
||||
GatewayProxyFactoryBean gatewayProxyFactoryBean = new AnnotationGatewayProxyFactoryBean(serviceInterface);
|
||||
|
||||
@@ -341,7 +341,7 @@ public abstract class AbstractPollingEndpoint extends AbstractEndpoint implement
|
||||
failedMessage = ((IntegrationResourceHolder) resource).getMessage();
|
||||
}
|
||||
}
|
||||
throw new MessagingException(failedMessage, e);
|
||||
throw new MessagingException(failedMessage, e); // NOSONAR (null failedMessage)
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-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.
|
||||
@@ -92,7 +92,8 @@ public class GatewayMessageHandler extends AbstractReplyProducingMessageHandler
|
||||
BeanFactory beanFactory = getBeanFactory();
|
||||
|
||||
if (beanFactory instanceof ConfigurableListableBeanFactory) {
|
||||
((ConfigurableListableBeanFactory) beanFactory).initializeBean(this.gatewayProxyFactoryBean, null);
|
||||
((ConfigurableListableBeanFactory) beanFactory).initializeBean(this.gatewayProxyFactoryBean,
|
||||
getComponentName() + "#gpfb");
|
||||
}
|
||||
try {
|
||||
this.exchanger = (RequestReplyExchanger) this.gatewayProxyFactoryBean.getObject();
|
||||
|
||||
@@ -118,20 +118,25 @@ class GatewayMethodInboundMessageMapper implements InboundMessageMapper<Object[]
|
||||
this(method, null);
|
||||
}
|
||||
|
||||
GatewayMethodInboundMessageMapper(Method method, Map<String, Expression> headerExpressions) {
|
||||
GatewayMethodInboundMessageMapper(Method method, @Nullable Map<String, Expression> headerExpressions) {
|
||||
this(method, headerExpressions, null, null, null);
|
||||
}
|
||||
|
||||
GatewayMethodInboundMessageMapper(Method method, Map<String, Expression> headerExpressions,
|
||||
Map<String, Expression> globalHeaderExpressions, MethodArgsMessageMapper mapper,
|
||||
MessageBuilderFactory messageBuilderFactory) {
|
||||
GatewayMethodInboundMessageMapper(Method method,
|
||||
@Nullable Map<String, Expression> headerExpressions,
|
||||
@Nullable Map<String, Expression> globalHeaderExpressions,
|
||||
@Nullable MethodArgsMessageMapper mapper,
|
||||
@Nullable MessageBuilderFactory messageBuilderFactory) {
|
||||
this(method, headerExpressions, globalHeaderExpressions, null, mapper, messageBuilderFactory);
|
||||
}
|
||||
|
||||
GatewayMethodInboundMessageMapper(Method method, Map<String, Expression> headerExpressions,
|
||||
Map<String, Expression> globalHeaderExpressions, Map<String, Object> headers,
|
||||
MethodArgsMessageMapper mapper,
|
||||
MessageBuilderFactory messageBuilderFactory) {
|
||||
GatewayMethodInboundMessageMapper(Method method,
|
||||
@Nullable Map<String, Expression> headerExpressions,
|
||||
@Nullable Map<String, Expression> globalHeaderExpressions,
|
||||
@Nullable Map<String, Object> headers,
|
||||
@Nullable MethodArgsMessageMapper mapper,
|
||||
@Nullable MessageBuilderFactory messageBuilderFactory) {
|
||||
|
||||
Assert.notNull(method, "method must not be null");
|
||||
this.method = method;
|
||||
this.headerExpressions = headerExpressions;
|
||||
@@ -262,6 +267,7 @@ class GatewayMethodInboundMessageMapper implements InboundMessageMapper<Object[]
|
||||
return parameterList;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Expression parsePayloadExpression(Method method) {
|
||||
Expression expression = null;
|
||||
Annotation payload = method.getAnnotation(Payload.class);
|
||||
|
||||
@@ -63,6 +63,7 @@ import org.springframework.integration.support.DefaultMessageBuilderFactory;
|
||||
import org.springframework.integration.support.channel.BeanFactoryChannelResolver;
|
||||
import org.springframework.integration.support.management.TrackableComponent;
|
||||
import org.springframework.integration.support.utils.IntegrationUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
@@ -324,7 +325,7 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
|
||||
* {@link java.util.concurrent.Future} return types must be returned by the downstream flow.
|
||||
* @param executor The executor.
|
||||
*/
|
||||
public void setAsyncExecutor(Executor executor) {
|
||||
public void setAsyncExecutor(@Nullable Executor executor) {
|
||||
if (executor == null && logger.isInfoEnabled()) {
|
||||
logger.info("A null executor disables the async gateway; " +
|
||||
"methods returning Future<?> will run on the calling thread");
|
||||
@@ -474,6 +475,7 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Object invokeGatewayMethod(MethodInvocation invocation, boolean runningOnCallerThread) throws Exception {
|
||||
if (!this.initialized) {
|
||||
this.afterPropertiesSet();
|
||||
|
||||
@@ -471,6 +471,7 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
private Object doSendAndReceive(Object object, boolean shouldConvert) {
|
||||
this.initializeIfNecessary();
|
||||
Assert.notNull(object, "request must not be null");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2016 the original author or authors.
|
||||
* Copyright 2015-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.
|
||||
@@ -18,12 +18,14 @@ package org.springframework.integration.leader;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Base implementation of a {@link Candidate}.
|
||||
*
|
||||
* @author Janne Valkealahti
|
||||
* @author Gary Russell
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractCandidate implements Candidate {
|
||||
@@ -47,7 +49,7 @@ public abstract class AbstractCandidate implements Candidate {
|
||||
* @param id the identifier
|
||||
* @param role the role
|
||||
*/
|
||||
public AbstractCandidate(String id, String role) {
|
||||
public AbstractCandidate(@Nullable String id, @Nullable String role) {
|
||||
this.id = StringUtils.hasText(id) ? id : UUID.randomUUID().toString();
|
||||
this.role = StringUtils.hasText(role) ? role : DEFAULT_ROLE;
|
||||
}
|
||||
|
||||
@@ -280,6 +280,7 @@ public abstract class AbstractHeaderMapper<T> implements RequestReplyHeaderMappe
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
protected <V> V getHeaderIfAvailable(Map<String, Object> headers, String name, Class<V> type) {
|
||||
Object value = headers.get(name);
|
||||
if (value == null) {
|
||||
|
||||
@@ -40,7 +40,12 @@ public class DefaultErrorMessageStrategy implements ErrorMessageStrategy {
|
||||
public ErrorMessage buildErrorMessage(Throwable throwable, @Nullable AttributeAccessor attributes) {
|
||||
Object inputMessage = attributes == null ? null
|
||||
: attributes.getAttribute(ErrorMessageUtils.INPUT_MESSAGE_CONTEXT_KEY);
|
||||
return new ErrorMessage(throwable, inputMessage instanceof Message ? (Message<?>) inputMessage : null);
|
||||
if (inputMessage instanceof Message) {
|
||||
return new ErrorMessage(throwable, (Message<?>) inputMessage);
|
||||
}
|
||||
else {
|
||||
return new ErrorMessage(throwable);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -20,6 +20,7 @@ import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.integration.store.SimpleMessageStore;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -60,7 +61,7 @@ public class MutableMessage<T> implements Message<T>, Serializable {
|
||||
this(payload, (Map<String, Object>) null);
|
||||
}
|
||||
|
||||
public MutableMessage(T payload, Map<String, Object> headers) {
|
||||
public MutableMessage(T payload, @Nullable Map<String, Object> headers) {
|
||||
this(payload, new MutableMessageHeaders(headers));
|
||||
}
|
||||
|
||||
@@ -85,6 +86,7 @@ public class MutableMessage<T> implements Message<T>, Serializable {
|
||||
return this.headers.getRawHeaders();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder(getClass().getSimpleName());
|
||||
sb.append(" [payload=");
|
||||
|
||||
@@ -74,6 +74,7 @@ public class MutableMessageHeaders extends MessageHeaders {
|
||||
return super.getRawHeaders().remove(key);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static UUID extractId(@Nullable Map<String, Object> headers) {
|
||||
if (headers != null && headers.containsKey(MessageHeaders.ID)) {
|
||||
Object id = headers.get(MessageHeaders.ID);
|
||||
@@ -92,6 +93,7 @@ public class MutableMessageHeaders extends MessageHeaders {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Long extractTimestamp(@Nullable Map<String, Object> headers) {
|
||||
if (headers != null && headers.containsKey(MessageHeaders.TIMESTAMP)) {
|
||||
Object timestamp = headers.get(MessageHeaders.TIMESTAMP);
|
||||
|
||||
@@ -102,7 +102,7 @@ public class MicrometerMetricsCaptor implements MetricsCaptor {
|
||||
}
|
||||
}
|
||||
|
||||
private class MicroSample implements SampleFacade {
|
||||
private static class MicroSample implements SampleFacade {
|
||||
|
||||
private final Timer.Sample sample;
|
||||
|
||||
|
||||
@@ -52,7 +52,8 @@ public final class IntegrationUtils {
|
||||
/**
|
||||
* Should be set to TRUE on CI plans and framework developer systems.
|
||||
*/
|
||||
public static final boolean fatalWhenNoBeanFactory = Boolean.valueOf(System.getenv("SI_FATAL_WHEN_NO_BEANFACTORY"));
|
||||
public static final boolean fatalWhenNoBeanFactory =
|
||||
Boolean.valueOf(System.getenv("SI_FATAL_WHEN_NO_BEANFACTORY"));
|
||||
|
||||
private IntegrationUtils() {
|
||||
super();
|
||||
@@ -154,7 +155,9 @@ public final class IntegrationUtils {
|
||||
* @return the wrapper, if necessary, or the original exception.
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public static RuntimeException wrapInDeliveryExceptionIfNecessary(Message<?> message, Supplier<String> text, Exception e) {
|
||||
public static RuntimeException wrapInDeliveryExceptionIfNecessary(Message<?> message, Supplier<String> text,
|
||||
Exception e) {
|
||||
|
||||
RuntimeException runtimeException = (e instanceof RuntimeException)
|
||||
? (RuntimeException) e
|
||||
: new MessageDeliveryException(message, text.get(), e);
|
||||
@@ -175,7 +178,9 @@ public final class IntegrationUtils {
|
||||
* @return the wrapper, if necessary, or the original exception.
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public static RuntimeException wrapInHandlingExceptionIfNecessary(Message<?> message, Supplier<String> text, Exception e) {
|
||||
public static RuntimeException wrapInHandlingExceptionIfNecessary(Message<?> message, Supplier<String> text,
|
||||
Exception e) {
|
||||
|
||||
RuntimeException runtimeException = (e instanceof RuntimeException)
|
||||
? (RuntimeException) e
|
||||
: new MessageHandlingException(message, text.get(), e);
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.integration.transaction;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
@@ -33,6 +35,7 @@ import org.springframework.util.StringUtils;
|
||||
* from JavaConfig to populate {@link DefaultTransactionSynchronizationFactory} bean.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @since 4.0
|
||||
*/
|
||||
public class TransactionSynchronizationFactoryBean implements FactoryBean<DefaultTransactionSynchronizationFactory>,
|
||||
@@ -40,6 +43,8 @@ public class TransactionSynchronizationFactoryBean implements FactoryBean<Defaul
|
||||
|
||||
private final SpelExpressionParser PARSER = new SpelExpressionParser();
|
||||
|
||||
private final AtomicInteger counter = new AtomicInteger();
|
||||
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
private volatile String beforeCommitExpression;
|
||||
@@ -199,7 +204,8 @@ public class TransactionSynchronizationFactoryBean implements FactoryBean<Defaul
|
||||
}
|
||||
|
||||
if (this.beanFactory instanceof AutowireCapableBeanFactory) {
|
||||
((AutowireCapableBeanFactory) this.beanFactory).initializeBean(processor, null);
|
||||
((AutowireCapableBeanFactory) this.beanFactory).initializeBean(processor,
|
||||
getClass().getName() + "#" + TransactionSynchronizationFactoryBean.this.counter.incrementAndGet());
|
||||
}
|
||||
|
||||
return new DefaultTransactionSynchronizationFactory(processor);
|
||||
|
||||
@@ -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.
|
||||
@@ -318,7 +318,7 @@ public class ContentEnricher extends AbstractReplyProducingMessageHandler implem
|
||||
|
||||
StandardEvaluationContext targetContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory());
|
||||
// bean resolution is NOT allowed for the target of the enrichment
|
||||
targetContext.setBeanResolver(null);
|
||||
targetContext.setBeanResolver(null); // NOSONAR (null)
|
||||
this.targetEvaluationContext = targetContext;
|
||||
|
||||
if (getBeanFactory() != null) {
|
||||
|
||||
@@ -48,6 +48,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @author Josh Long
|
||||
* @author Gunnar Hillert
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@@ -68,7 +69,7 @@ public class XmppHeaderEnricherParserTests {
|
||||
CountDownLatch callLatch = new CountDownLatch(1);
|
||||
MessageHandler handler = mock(MessageHandler.class);
|
||||
willAnswer(invocation -> {
|
||||
Message message = invocation.getArgument(0);
|
||||
Message<?> message = invocation.getArgument(0);
|
||||
String chatToUser = (String) message.getHeaders().get(XmppHeaders.TO);
|
||||
assertNotNull(chatToUser);
|
||||
assertEquals("test1@example.org", chatToUser);
|
||||
|
||||
Reference in New Issue
Block a user