More Sonar fixes
This commit is contained in:
@@ -165,18 +165,19 @@ public class CamelMessageHandler extends AbstractReplyProducingMessageHandler {
|
||||
"The 'endpointUri' option is mutually exclusive with 'route'");
|
||||
|
||||
BeanFactory beanFactory = getBeanFactory();
|
||||
if (this.producerTemplate == null) {
|
||||
if (this.producerTemplate == null) { // NOSONAR
|
||||
this.producerTemplate = beanFactory.getBean(CamelContext.class).createProducerTemplate();
|
||||
}
|
||||
|
||||
if (this.route != null) {
|
||||
LambdaRouteBuilder lambdaRouteBuilder = this.route;
|
||||
if (lambdaRouteBuilder != null) {
|
||||
CamelContext camelContext = this.producerTemplate.getCamelContext();
|
||||
RouteBuilder routeBuilder =
|
||||
new RouteBuilder(camelContext) {
|
||||
|
||||
@Override
|
||||
public void configure() throws Exception {
|
||||
CamelMessageHandler.this.route.accept(this);
|
||||
lambdaRouteBuilder.accept(this);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -92,6 +92,8 @@ public class IntegrationComponentScanRegistrar implements ImportBeanDefinitionRe
|
||||
AnnotationAttributes.fromMap(
|
||||
importingClassMetadata.getAnnotationAttributes(IntegrationComponentScan.class.getName()));
|
||||
|
||||
Assert.notNull(componentScan, "The '@IntegrationComponentScan' must be present for using this registrar");
|
||||
|
||||
Collection<String> basePackages = getBasePackages(componentScan, registry);
|
||||
|
||||
if (basePackages.isEmpty()) {
|
||||
|
||||
@@ -134,7 +134,7 @@ public class MessagingAnnotationPostProcessor
|
||||
|
||||
private void processCandidate(String beanName, AnnotatedBeanDefinition beanDefinition) {
|
||||
MethodMetadata methodMetadata = beanDefinition.getFactoryMethodMetadata();
|
||||
MergedAnnotations annotations = methodMetadata.getAnnotations();
|
||||
MergedAnnotations annotations = methodMetadata.getAnnotations(); // NOSONAR
|
||||
if (methodMetadata instanceof StandardMethodMetadata standardMethodMetadata) {
|
||||
annotations = MergedAnnotations.from(standardMethodMetadata.getIntrospectedMethod());
|
||||
}
|
||||
@@ -179,7 +179,7 @@ public class MessagingAnnotationPostProcessor
|
||||
if (messagingAnnotationProcessor != null) {
|
||||
if (messagingAnnotationProcessor.beanAnnotationAware()) {
|
||||
if (messagingAnnotationProcessor.shouldCreateEndpoint(
|
||||
beanDefinition.getFactoryMethodMetadata().getAnnotations(), annotationChain)) {
|
||||
beanDefinition.getFactoryMethodMetadata().getAnnotations(), annotationChain)) { // NOSONAR
|
||||
|
||||
messagingAnnotationProcessor.processBeanDefinition(beanName, beanDefinition, annotationChain);
|
||||
}
|
||||
@@ -311,11 +311,10 @@ public class MessagingAnnotationPostProcessor
|
||||
MethodAnnotationPostProcessor<?> postProcessor, Method targetMethod) {
|
||||
|
||||
Object result = postProcessor.postProcess(bean, beanName, targetMethod, annotations);
|
||||
ConfigurableListableBeanFactory beanFactory = getBeanFactory();
|
||||
if (result instanceof AbstractEndpoint endpoint) {
|
||||
String autoStartup = MessagingAnnotationUtils.resolveAttribute(annotations, "autoStartup", String.class);
|
||||
if (StringUtils.hasText(autoStartup)) {
|
||||
autoStartup = beanFactory.resolveEmbeddedValue(autoStartup);
|
||||
autoStartup = this.beanFactory.resolveEmbeddedValue(autoStartup);
|
||||
if (StringUtils.hasText(autoStartup)) {
|
||||
endpoint.setAutoStartup(Boolean.parseBoolean(autoStartup));
|
||||
}
|
||||
@@ -323,7 +322,7 @@ public class MessagingAnnotationPostProcessor
|
||||
|
||||
String phase = MessagingAnnotationUtils.resolveAttribute(annotations, "phase", String.class);
|
||||
if (StringUtils.hasText(phase)) {
|
||||
phase = beanFactory.resolveEmbeddedValue(phase);
|
||||
phase = this.beanFactory.resolveEmbeddedValue(phase);
|
||||
if (StringUtils.hasText(phase)) {
|
||||
endpoint.setPhase(Integer.parseInt(phase));
|
||||
}
|
||||
@@ -339,7 +338,7 @@ public class MessagingAnnotationPostProcessor
|
||||
getBeanDefinitionRegistry()
|
||||
.registerBeanDefinition(endpointBeanName,
|
||||
new RootBeanDefinition((Class<AbstractEndpoint>) endpoint.getClass(), () -> endpoint));
|
||||
beanFactory.getBean(endpointBeanName);
|
||||
this.beanFactory.getBean(endpointBeanName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,8 +351,7 @@ public class MessagingAnnotationPostProcessor
|
||||
+ ClassUtils.getShortNameAsProperty(annotationType);
|
||||
name = baseName;
|
||||
int count = 1;
|
||||
ConfigurableListableBeanFactory beanFactory = getBeanFactory();
|
||||
while (beanFactory.containsBean(name)) {
|
||||
while (this.beanFactory.containsBean(name)) {
|
||||
name = baseName + "#" + (++count);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,10 @@ public class GatewayParser implements BeanDefinitionParser {
|
||||
|
||||
private static final String PROXY_DEFAULT_METHODS_ATTR = "proxyDefaultMethods";
|
||||
|
||||
private static final String ASYNC_EXECUTOR_ATTR = "asyncExecutor";
|
||||
|
||||
private static final String MAPPER_ATTR = "mapper";
|
||||
|
||||
@Override
|
||||
public BeanDefinition parse(final Element element, ParserContext parserContext) {
|
||||
boolean isNested = parserContext.isNested();
|
||||
@@ -83,13 +87,13 @@ public class GatewayParser implements BeanDefinitionParser {
|
||||
|
||||
String asyncExecutor = element.getAttribute("async-executor");
|
||||
if (!element.hasAttribute("async-executor") || StringUtils.hasLength(asyncExecutor)) {
|
||||
gatewayAttributes.put("asyncExecutor", asyncExecutor);
|
||||
gatewayAttributes.put(ASYNC_EXECUTOR_ATTR, asyncExecutor);
|
||||
}
|
||||
else {
|
||||
gatewayAttributes.put("asyncExecutor", null);
|
||||
gatewayAttributes.put(ASYNC_EXECUTOR_ATTR, null);
|
||||
}
|
||||
|
||||
gatewayAttributes.put("mapper", element.getAttribute("mapper"));
|
||||
gatewayAttributes.put(MAPPER_ATTR, element.getAttribute(MAPPER_ATTR));
|
||||
gatewayAttributes.put("defaultReplyTimeout",
|
||||
element.getAttribute(isNested ? "reply-timeout" : "default-reply-timeout"));
|
||||
gatewayAttributes.put("defaultRequestTimeout",
|
||||
@@ -122,8 +126,10 @@ public class GatewayParser implements BeanDefinitionParser {
|
||||
Map<String, Object> header = new HashMap<>();
|
||||
header.put(AbstractBeanDefinitionParser.NAME_ATTRIBUTE,
|
||||
e.getAttribute(AbstractBeanDefinitionParser.NAME_ATTRIBUTE));
|
||||
header.put("value", e.getAttribute("value"));
|
||||
header.put("expression", e.getAttribute("expression"));
|
||||
header.put(IntegrationNamespaceUtils.VALUE_ATTRIBUTE,
|
||||
e.getAttribute(IntegrationNamespaceUtils.VALUE_ATTRIBUTE));
|
||||
header.put(IntegrationNamespaceUtils.EXPRESSION_ATTRIBUTE,
|
||||
e.getAttribute(IntegrationNamespaceUtils.EXPRESSION_ATTRIBUTE));
|
||||
headers.add(header);
|
||||
}
|
||||
gatewayAttributes.put("defaultHeaders", headers.toArray(new Map<?, ?>[0]));
|
||||
@@ -146,7 +152,7 @@ public class GatewayParser implements BeanDefinitionParser {
|
||||
methodMetadataBuilder.addPropertyValue("requestTimeout", methodElement.getAttribute("request-timeout"));
|
||||
methodMetadataBuilder.addPropertyValue("replyTimeout", methodElement.getAttribute("reply-timeout"));
|
||||
|
||||
boolean hasMapper = StringUtils.hasText(element.getAttribute("mapper"));
|
||||
boolean hasMapper = StringUtils.hasText(element.getAttribute(MAPPER_ATTR));
|
||||
String payloadExpression = methodElement.getAttribute("payload-expression");
|
||||
Assert.state(!hasMapper || !StringUtils.hasText(payloadExpression),
|
||||
"'payload-expression' is not allowed when a 'mapper' is provided");
|
||||
@@ -165,7 +171,8 @@ public class GatewayParser implements BeanDefinitionParser {
|
||||
Map<String, Object> headerExpressions = new ManagedMap<>();
|
||||
for (Element headerElement : invocationHeaders) {
|
||||
BeanDefinition expressionDef = IntegrationNamespaceUtils
|
||||
.createExpressionDefinitionFromValueOrExpression("value", "expression", parserContext,
|
||||
.createExpressionDefinitionFromValueOrExpression(
|
||||
IntegrationNamespaceUtils.VALUE_ATTRIBUTE, "expression", parserContext,
|
||||
headerElement, true);
|
||||
|
||||
headerExpressions.put(headerElement.getAttribute(AbstractBeanDefinitionParser.NAME_ATTRIBUTE),
|
||||
@@ -193,8 +200,8 @@ public class GatewayParser implements BeanDefinitionParser {
|
||||
String defaultRequestChannel = (String) gatewayAttributes.get("defaultRequestChannel");
|
||||
String defaultReplyChannel = (String) gatewayAttributes.get("defaultReplyChannel");
|
||||
String errorChannel = (String) gatewayAttributes.get("errorChannel");
|
||||
String asyncExecutor = (String) gatewayAttributes.get("asyncExecutor");
|
||||
String mapper = (String) gatewayAttributes.get("mapper");
|
||||
String asyncExecutor = (String) gatewayAttributes.get(ASYNC_EXECUTOR_ATTR);
|
||||
String mapper = (String) gatewayAttributes.get(MAPPER_ATTR);
|
||||
String proxyDefaultMethods = (String) gatewayAttributes.get(PROXY_DEFAULT_METHODS_ATTR);
|
||||
|
||||
boolean hasMapper = StringUtils.hasText(mapper);
|
||||
@@ -229,13 +236,13 @@ public class GatewayParser implements BeanDefinitionParser {
|
||||
gatewayProxyBuilder.addPropertyValue("errorChannelName", errorChannel);
|
||||
}
|
||||
if (asyncExecutor == null || AnnotationConstants.NULL.equals(asyncExecutor)) {
|
||||
gatewayProxyBuilder.addPropertyValue("asyncExecutor", null);
|
||||
gatewayProxyBuilder.addPropertyValue(ASYNC_EXECUTOR_ATTR, null);
|
||||
}
|
||||
else if (StringUtils.hasText(asyncExecutor)) {
|
||||
gatewayProxyBuilder.addPropertyReference("asyncExecutor", asyncExecutor);
|
||||
gatewayProxyBuilder.addPropertyReference(ASYNC_EXECUTOR_ATTR, asyncExecutor);
|
||||
}
|
||||
if (StringUtils.hasText(mapper)) {
|
||||
gatewayProxyBuilder.addPropertyReference("mapper", mapper);
|
||||
gatewayProxyBuilder.addPropertyReference(MAPPER_ATTR, mapper);
|
||||
}
|
||||
if (StringUtils.hasText(proxyDefaultMethods)) {
|
||||
gatewayProxyBuilder.addPropertyValue(PROXY_DEFAULT_METHODS_ATTR, proxyDefaultMethods);
|
||||
@@ -247,7 +254,7 @@ public class GatewayParser implements BeanDefinitionParser {
|
||||
gatewayAttributes.get("defaultReplyTimeout"));
|
||||
gatewayProxyBuilder.addPropertyValue("methodMetadataMap", gatewayAttributes.get("methods"));
|
||||
|
||||
String id = (String) gatewayAttributes.get("name");
|
||||
String id = (String) gatewayAttributes.get(AbstractBeanDefinitionParser.NAME_ATTRIBUTE);
|
||||
if (!StringUtils.hasText(id)) {
|
||||
BeanNameGenerator beanNameGenerator =
|
||||
IntegrationConfigUtils.annotationBeanNameGenerator(registry);
|
||||
@@ -281,8 +288,8 @@ public class GatewayParser implements BeanDefinitionParser {
|
||||
if (!ObjectUtils.isEmpty(defaultHeaders)) {
|
||||
Map<String, Object> headerExpressions = new ManagedMap<>();
|
||||
for (Map<String, Object> header : defaultHeaders) {
|
||||
String headerValue = (String) header.get("value");
|
||||
String headerExpression = (String) header.get("expression");
|
||||
String headerValue = (String) header.get(IntegrationNamespaceUtils.VALUE_ATTRIBUTE);
|
||||
String headerExpression = (String) header.get(IntegrationNamespaceUtils.EXPRESSION_ATTRIBUTE);
|
||||
boolean hasValue = StringUtils.hasText(headerValue);
|
||||
|
||||
if (hasValue == StringUtils.hasText(headerExpression)) {
|
||||
@@ -295,7 +302,7 @@ public class GatewayParser implements BeanDefinitionParser {
|
||||
expressionDef.getConstructorArgumentValues()
|
||||
.addGenericArgumentValue(hasValue ? headerValue : headerExpression);
|
||||
|
||||
headerExpressions.put((String) header.get("name"), expressionDef);
|
||||
headerExpressions.put((String) header.get(AbstractBeanDefinitionParser.NAME_ATTRIBUTE), expressionDef);
|
||||
}
|
||||
methodMetadataBuilder.addPropertyValue("headerExpressions", headerExpressions);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -71,6 +71,8 @@ public abstract class IntegrationNamespaceUtils {
|
||||
|
||||
public static final String REF_ATTRIBUTE = "ref";
|
||||
|
||||
public static final String VALUE_ATTRIBUTE = "value";
|
||||
|
||||
public static final String METHOD_ATTRIBUTE = "method";
|
||||
|
||||
public static final String ORDER = "order";
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Provides classes for Java DSL to support GraphQL components.
|
||||
*/
|
||||
package org.springframework.integration.graphql.dsl;
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
* Copyright 2015-2022 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.
|
||||
@@ -78,59 +78,55 @@ public class HazelcastCacheWritingMessageHandler extends AbstractMessageHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
protected void handleMessageInternal(final Message<?> message) {
|
||||
Object objectToStore = message;
|
||||
if (this.extractPayload) {
|
||||
objectToStore = message.getPayload();
|
||||
}
|
||||
|
||||
DistributedObject distributedObject = getDistributedObject(message);
|
||||
DistributedObject object = getDistributedObject(message);
|
||||
|
||||
if (distributedObject instanceof Map) {
|
||||
Map map = (Map) distributedObject;
|
||||
if (object instanceof Map map) {
|
||||
if (objectToStore instanceof Map) {
|
||||
map.putAll((Map) objectToStore);
|
||||
}
|
||||
else if (objectToStore instanceof Map.Entry) {
|
||||
Map.Entry entry = (Map.Entry) objectToStore;
|
||||
else if (objectToStore instanceof Map.Entry entry) {
|
||||
map.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
else {
|
||||
map.put(getKey(message), objectToStore);
|
||||
}
|
||||
}
|
||||
else if (distributedObject instanceof MultiMap) {
|
||||
MultiMap map = (MultiMap) distributedObject;
|
||||
else if (object instanceof MultiMap map) {
|
||||
if (objectToStore instanceof Map) {
|
||||
Map<?, ?> mapToStore = (Map) objectToStore;
|
||||
for (Map.Entry entry : mapToStore.entrySet()) {
|
||||
map.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
else if (objectToStore instanceof Map.Entry) {
|
||||
Map.Entry entry = (Map.Entry) objectToStore;
|
||||
else if (objectToStore instanceof Map.Entry entry) {
|
||||
map.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
else {
|
||||
map.put(getKey(message), objectToStore);
|
||||
}
|
||||
}
|
||||
else if (distributedObject instanceof ITopic) {
|
||||
((ITopic) distributedObject).publish(objectToStore);
|
||||
else if (object instanceof ITopic) {
|
||||
((ITopic) object).publish(objectToStore);
|
||||
}
|
||||
else if (distributedObject instanceof Collection) {
|
||||
else if (object instanceof Collection) {
|
||||
if (objectToStore instanceof Collection) {
|
||||
((Collection) distributedObject).addAll((Collection) objectToStore);
|
||||
((Collection) object).addAll((Collection) objectToStore);
|
||||
}
|
||||
else {
|
||||
((Collection) distributedObject).add(objectToStore);
|
||||
((Collection) object).add(objectToStore);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException("The 'distributedObject' for 'HazelcastCacheWritingMessageHandler' " +
|
||||
throw new IllegalStateException("The 'object' for 'HazelcastCacheWritingMessageHandler' " +
|
||||
"must be of 'IMap', 'MultiMap', 'ITopic', 'ISet' or 'IList' type, " +
|
||||
"but gotten: [" + distributedObject + "].");
|
||||
"but gotten: [" + object + "].");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +140,7 @@ public class HazelcastCacheWritingMessageHandler extends AbstractMessageHandler
|
||||
}
|
||||
else if (message.getHeaders().containsKey(HazelcastHeaders.CACHE_NAME)) {
|
||||
return getBeanFactory()
|
||||
.getBean(message.getHeaders().get(HazelcastHeaders.CACHE_NAME, String.class),
|
||||
.getBean(message.getHeaders().get(HazelcastHeaders.CACHE_NAME, String.class), // NOSONAR
|
||||
DistributedObject.class);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -257,10 +257,10 @@ public abstract class TestUtils {
|
||||
try {
|
||||
sent = errorChannel.send(new ErrorMessage(throwable), 10000); // NOSONAR
|
||||
}
|
||||
catch (Throwable errorDeliveryError) { //NOSONAR
|
||||
catch (Throwable errorDeliveryError) { // NOSONAR
|
||||
// message will be logged only
|
||||
logger.warn("Error message was not delivered.", errorDeliveryError);
|
||||
if (errorDeliveryError instanceof Error) { // NOSONAR
|
||||
if (errorDeliveryError instanceof Error) { // NOSONAR
|
||||
throw (Error) errorDeliveryError;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user