Sonar Fixes
Critical smells `o.s.i.h*`.
This commit is contained in:
committed by
Artem Bilan
parent
536b6b1786
commit
4760c54097
@@ -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.
|
||||
@@ -25,6 +25,7 @@ import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.integration.handler.support.MessagingMethodInvokerHelper;
|
||||
import org.springframework.integration.util.AbstractExpressionEvaluator;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
@@ -32,6 +33,7 @@ import org.springframework.messaging.Message;
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @since 2.0
|
||||
*/
|
||||
public class MethodInvokingMessageListProcessor<T> extends AbstractExpressionEvaluator
|
||||
@@ -61,7 +63,7 @@ public class MethodInvokingMessageListProcessor<T> extends AbstractExpressionEva
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
public void setBeanFactory(@NonNull BeanFactory beanFactory) {
|
||||
super.setBeanFactory(beanFactory);
|
||||
this.delegate.setBeanFactory(beanFactory);
|
||||
}
|
||||
@@ -77,6 +79,7 @@ public class MethodInvokingMessageListProcessor<T> extends AbstractExpressionEva
|
||||
this.delegate.setUseSpelInvoker(useSpelInvoker);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.delegate.toString();
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -23,6 +23,7 @@ import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.integration.handler.support.MessagingMethodInvokerHelper;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHandlingException;
|
||||
|
||||
@@ -37,6 +38,7 @@ import org.springframework.messaging.MessageHandlingException;
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@@ -67,7 +69,7 @@ public class MethodInvokingMessageProcessor<T> extends AbstractMessageProcessor<
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
public void setBeanFactory(@NonNull BeanFactory beanFactory) {
|
||||
super.setBeanFactory(beanFactory);
|
||||
this.delegate.setBeanFactory(beanFactory);
|
||||
}
|
||||
|
||||
@@ -86,18 +86,25 @@ public class ErrorMessageSendingRecoverer extends ErrorMessagePublisher implemen
|
||||
|
||||
@Override
|
||||
protected Throwable payloadWhenNull(AttributeAccessor context) {
|
||||
return new RetryExceptionNotAvailableException(
|
||||
(Message<?>) context.getAttribute(ErrorMessageUtils.FAILED_MESSAGE_CONTEXT_KEY),
|
||||
"No retry exception available; " +
|
||||
"this can occur, for example, if the RetryPolicy allowed zero attempts " +
|
||||
"to execute the handler; " +
|
||||
"RetryContext: " + context.toString());
|
||||
Message<?> message = (Message<?>) context.getAttribute(ErrorMessageUtils.FAILED_MESSAGE_CONTEXT_KEY);
|
||||
String description = "No retry exception available; " +
|
||||
"this can occur, for example, if the RetryPolicy allowed zero attempts " +
|
||||
"to execute the handler; " +
|
||||
"RetryContext: " + context.toString();
|
||||
return message == null
|
||||
? new RetryExceptionNotAvailableException(description)
|
||||
: new RetryExceptionNotAvailableException(message, description);
|
||||
}
|
||||
|
||||
public static class RetryExceptionNotAvailableException extends MessagingException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
RetryExceptionNotAvailableException(String description) {
|
||||
super(description);
|
||||
}
|
||||
|
||||
public RetryExceptionNotAvailableException(Message<?> message, String description) {
|
||||
super(message, description);
|
||||
}
|
||||
|
||||
@@ -171,10 +171,6 @@ public class IdempotentReceiverInterceptor extends AbstractHandleMessageAdvice {
|
||||
private MessageChannel obtainDiscardChannel() {
|
||||
if (this.discardChannel == null) {
|
||||
if (this.discardChannelName != null) {
|
||||
if (getChannelResolver() == null) {
|
||||
throw new IllegalStateException("No channel resolver available to resolve the discard channel '"
|
||||
+ this.discardChannelName + "'");
|
||||
}
|
||||
this.discardChannel = getChannelResolver()
|
||||
.resolveDestination(this.discardChannelName);
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ public class SpelExpressionRetryStateGenerator implements RetryStateGenerator, B
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(beanFactory);
|
||||
}
|
||||
@@ -69,11 +70,13 @@ public class SpelExpressionRetryStateGenerator implements RetryStateGenerator, B
|
||||
this.classifier = classifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RetryState determineRetryState(Message<?> message) {
|
||||
Boolean forceRefresh = this.forceRefreshExpression == null
|
||||
? Boolean.FALSE
|
||||
: this.forceRefreshExpression.getValue(this.evaluationContext, message, Boolean.class);
|
||||
return new DefaultRetryState(this.keyExpression.getValue(this.evaluationContext, message),
|
||||
this.forceRefreshExpression == null
|
||||
? false
|
||||
: this.forceRefreshExpression.getValue(this.evaluationContext, message, Boolean.class),
|
||||
forceRefresh == null ? false : forceRefresh,
|
||||
this.classifier);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,6 +84,7 @@ import org.springframework.integration.util.ClassUtils;
|
||||
import org.springframework.integration.util.FixedMethodFilter;
|
||||
import org.springframework.integration.util.MessagingAnnotationUtils;
|
||||
import org.springframework.integration.util.UniqueMethodFilter;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHandlingException;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
@@ -155,7 +156,8 @@ public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator
|
||||
private static final Collection<Message<?>> dummyMessages = Collections.emptyList();
|
||||
|
||||
private static final TypeDescriptor messageListTypeDescriptor =
|
||||
new TypeDescriptor(ReflectionUtils.findField(MessagingMethodInvokerHelper.class, "dummyMessages"));
|
||||
new TypeDescriptor(ReflectionUtils.findField(MessagingMethodInvokerHelper.class, // NOSONAR never null
|
||||
"dummyMessages"));
|
||||
|
||||
private static final TypeDescriptor messageArrayTypeDescriptor = TypeDescriptor.valueOf(Message[].class);
|
||||
|
||||
@@ -291,7 +293,7 @@ public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
public void setBeanFactory(@NonNull BeanFactory beanFactory) {
|
||||
super.setBeanFactory(beanFactory);
|
||||
this.messageHandlerMethodFactory.setBeanFactory(beanFactory);
|
||||
if (beanFactory instanceof ConfigurableListableBeanFactory) {
|
||||
|
||||
@@ -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.
|
||||
@@ -32,6 +32,7 @@ import org.springframework.util.StringUtils;
|
||||
* as a SpEL expression against {@code message} and converting result to expected parameter type.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 5.0
|
||||
*
|
||||
@@ -53,7 +54,7 @@ public class PayloadExpressionArgumentResolver extends AbstractExpressionEvaluat
|
||||
Expression expression = this.expressionCache.get(parameter);
|
||||
if (expression == null) {
|
||||
Payload ann = parameter.getParameterAnnotation(Payload.class);
|
||||
expression = EXPRESSION_PARSER.parseExpression(ann.expression());
|
||||
expression = EXPRESSION_PARSER.parseExpression(ann.expression()); // NOSONAR never null - supportsParameter()
|
||||
this.expressionCache.put(parameter, expression);
|
||||
}
|
||||
return evaluateExpression(expression, message.getPayload(), parameter.getParameterType());
|
||||
|
||||
@@ -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.
|
||||
@@ -62,7 +62,7 @@ public class PayloadsArgumentResolver extends AbstractExpressionEvaluator
|
||||
Collection<Message<?>> messages = (Collection<Message<?>>) payload;
|
||||
|
||||
if (!this.expressionCache.containsKey(parameter)) {
|
||||
Payloads payloads = parameter.getParameterAnnotation(Payloads.class);
|
||||
Payloads payloads = parameter.getParameterAnnotation(Payloads.class); // NOSONAR never null - supportsParameter()
|
||||
String expression = payloads.value();
|
||||
if (StringUtils.hasText(expression)) {
|
||||
this.expressionCache.put(parameter, EXPRESSION_PARSER.parseExpression("![payload." + expression + "]"));
|
||||
|
||||
Reference in New Issue
Block a user