Fix new sonar smells

This commit is contained in:
Artem Bilan
2020-05-28 09:56:39 -04:00
parent b8e2dfe4e1
commit 5bd6278fcb
3 changed files with 20 additions and 23 deletions

View File

@@ -62,7 +62,6 @@ import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.integration.endpoint.AbstractEndpoint;
import org.springframework.integration.expression.ExpressionUtils;
import org.springframework.integration.expression.ValueExpression;
import org.springframework.integration.support.DefaultMessageBuilderFactory;
import org.springframework.integration.support.channel.ChannelResolverUtils;
import org.springframework.integration.support.management.TrackableComponent;
import org.springframework.integration.util.JavaUtils;
@@ -873,7 +872,7 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
headers, this.argsMapper, getMessageBuilderFactory());
}
@Nullable
@Nullable // NOSONAR - complexitty
private Map<String, Object> headers(Method method, Map<String, Expression> headerExpressions) {
Map<String, Object> headers = null;
// We don't want to eagerly resolve the error channel here
@@ -896,25 +895,23 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
headers.put(MessageHeaders.REPLY_CHANNEL, IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME);
}
if (getMessageBuilderFactory() instanceof DefaultMessageBuilderFactory) {
Set<String> headerNames = new HashSet<>(headerExpressions.keySet());
Set<String> headerNames = new HashSet<>(headerExpressions.keySet());
if (this.globalMethodMetadata != null) {
headerNames.addAll(this.globalMethodMetadata.getHeaderExpressions().keySet());
}
List<MethodParameter> methodParameters = GatewayMethodInboundMessageMapper.getMethodParameterList(method);
for (MethodParameter methodParameter : methodParameters) {
Header header = methodParameter.getParameterAnnotation(Header.class);
if (header != null) {
String headerName = GatewayMethodInboundMessageMapper.determineHeaderName(header, methodParameter);
headerNames.add(headerName);
}
}
validateHeaders(headerNames);
if (this.globalMethodMetadata != null) {
headerNames.addAll(this.globalMethodMetadata.getHeaderExpressions().keySet());
}
List<MethodParameter> methodParameters = GatewayMethodInboundMessageMapper.getMethodParameterList(method);
for (MethodParameter methodParameter : methodParameters) {
Header header = methodParameter.getParameterAnnotation(Header.class);
if (header != null) {
String headerName = GatewayMethodInboundMessageMapper.determineHeaderName(header, methodParameter);
headerNames.add(headerName);
}
}
validateHeaders(headerNames);
return headers;
}

View File

@@ -17,7 +17,6 @@
package org.springframework.integration.util;
import java.time.Duration;
import java.util.function.Function;
import org.reactivestreams.Publisher;
@@ -47,7 +46,7 @@ public final class IntegrationReactiveUtils {
/**
* The subscriber context entry for {@link Flux#delayElements}
* from the {@link Mono#repeatWhenEmpty(Function)}.
* from the {@link Mono#repeatWhenEmpty(java.util.function.Function)}.
*/
public static final String DELAY_WHEN_EMPTY_KEY = "DELAY_WHEN_EMPTY_KEY";

View File

@@ -162,8 +162,9 @@ public class MockIntegrationContext implements BeanFactoryAware {
substituteMessageHandlerFor(consumerEndpointId, mockMessageHandler, true);
}
public void substituteMessageHandlerFor(String consumerEndpointId, MessageHandler mockMessageHandler,
boolean autoStartup) {
public void substituteMessageHandlerFor(String consumerEndpointId, // NOSONAR - complexity
MessageHandler mockMessageHandler, boolean autoStartup) {
Object endpoint = this.beanFactory.getBean(consumerEndpointId, IntegrationConsumer.class);
if (autoStartup && endpoint instanceof Lifecycle) {
((Lifecycle) endpoint).stop();