More Sonar fixes

This commit is contained in:
Artem Bilan
2022-11-03 17:28:54 -04:00
parent 7084e9654a
commit d31f309752
15 changed files with 76 additions and 98 deletions

View File

@@ -187,12 +187,15 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
BeanDefinition handlerBeanDefinition =
resolveHandlerBeanDefinition(beanName, beanDefinition, handlerBeanType, annotations);
MergedAnnotations mergedAnnotations = beanDefinition.getFactoryMethodMetadata().getAnnotations();
MergedAnnotations mergedAnnotations =
beanDefinition.getFactoryMethodMetadata().getAnnotations(); // NOSONAR
if (handlerBeanDefinition != null) {
if (handlerBeanDefinition != beanDefinition) {
if (!handlerBeanDefinition.equals(beanDefinition)) {
String beanClassName = handlerBeanDefinition.getBeanClassName();
Assert.notNull(beanClassName, "No bean class present for " + handlerBeanDefinition);
Class<?> handlerBeanClass =
org.springframework.util.ClassUtils.resolveClassName(handlerBeanDefinition.getBeanClassName(),
org.springframework.util.ClassUtils.resolveClassName(beanClassName,
this.beanFactory.getBeanClassLoader());
if (isClassIn(handlerBeanClass, Orderable.class, AbstractSimpleMessageHandlerFactoryBean.class)) {
@@ -381,6 +384,7 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
return ResolvableType.forMethodReturnType(standardMethodMetadata.getIntrospectedMethod());
}
else {
Assert.notNull(factoryMethodMetadata, "No factoryMethodMetadata present for " + beanDefinition);
String typeName = factoryMethodMetadata.getReturnTypeName();
Class<?> beanClass =
org.springframework.util.ClassUtils.resolveClassName(typeName,

View File

@@ -16,9 +16,6 @@
package org.springframework.integration.context;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.config.BeanDefinition;
@@ -90,8 +87,6 @@ public abstract class IntegrationContextUtils {
public static final String GLOBAL_CHANNEL_INTERCEPTOR_PROCESSOR_BEAN_NAME = "globalChannelInterceptorProcessor";
public static final String JSON_NODE_WRAPPER_TO_JSON_NODE_CONVERTER = "jsonNodeWrapperToJsonNodeConverter";
public static final String INTEGRATION_LIFECYCLE_ROLE_CONTROLLER = "integrationLifecycleRoleController";
public static final String INTEGRATION_GRAPH_SERVER_BEAN_NAME = "integrationGraphServer";
@@ -106,8 +101,6 @@ public abstract class IntegrationContextUtils {
public static final String LIST_MESSAGE_HANDLER_FACTORY_BEAN_NAME = "integrationListMessageHandlerMethodFactory";
private static final Log LOGGER = LogFactory.getLog(IntegrationContextUtils.class);
/**
* @param beanFactory BeanFactory for lookup, must not be null.
* @return The {@link MetadataStore} bean whose name is "metadataStore".

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 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.
@@ -61,7 +61,9 @@ public class AggregateMessageDeliveryException extends MessageDeliveryException
StringBuilder message = new StringBuilder(appendPeriodIfNecessary(baseMessage))
.append(" Multiple causes:\n");
for (Exception exception : this.aggregatedExceptions) {
message.append(" " + exception.getMessage() + "\n");
message.append(" ")
.append(exception.getMessage())
.append("\n");
}
message.append("See below for the stacktrace of the first cause.");
return message.toString();

View File

@@ -53,7 +53,7 @@ public final class Pollers {
/**
* @deprecated since 6.0 in favor of {@link #fixedRate(Duration)}
*/
@Deprecated(since = "6.0", forRemoval = true)
@Deprecated(forRemoval = true)
public static PollerSpec fixedRate(long period, TimeUnit timeUnit) {
return fixedRate(Duration.of(period, timeUnit.toChronoUnit()));
}
@@ -69,7 +69,7 @@ public final class Pollers {
/**
* @deprecated since 6.0 in favor of {@link #fixedRate(Duration, Duration)}
*/
@Deprecated(since = "6.0", forRemoval = true)
@Deprecated(forRemoval = true)
public static PollerSpec fixedRate(long period, TimeUnit timeUnit, long initialDelay) {
ChronoUnit chronoUnit = timeUnit.toChronoUnit();
return fixedRate(Duration.of(period, chronoUnit), Duration.of(initialDelay, chronoUnit));
@@ -90,7 +90,7 @@ public final class Pollers {
/**
* @deprecated since 6.0 in favor of {@link #fixedDelay(Duration)}
*/
@Deprecated(since = "6.0", forRemoval = true)
@Deprecated(forRemoval = true)
public static PollerSpec fixedDelay(long period, TimeUnit timeUnit) {
return fixedDelay(Duration.of(period, timeUnit.toChronoUnit()));
}
@@ -102,7 +102,7 @@ public final class Pollers {
/**
* @deprecated since 6.0 in favor of {@link #fixedDelay(Duration, Duration)}
*/
@Deprecated(since = "6.0", forRemoval = true)
@Deprecated(forRemoval = true)
public static PollerSpec fixedDelay(long period, TimeUnit timeUnit, long initialDelay) {
ChronoUnit chronoUnit = timeUnit.toChronoUnit();
return fixedDelay(Duration.of(period, chronoUnit), Duration.of(initialDelay, chronoUnit));

View File

@@ -36,7 +36,7 @@ import org.springframework.util.ReflectionUtils;
/**
* Method interceptor to invoke default methods on the gateway proxy.
*
* <p>
* The copy of {@code DefaultMethodInvokingMethodInterceptor} from Spring Data Commons.
*
* @author Oliver Gierke
@@ -122,7 +122,7 @@ class DefaultMethodInvokingMethodInterceptor implements MethodInterceptor {
private volatile boolean constructorResolved;
private Constructor<Lookup> constructor;
private transient Constructor<Lookup> constructor;
private final Supplier<Constructor<Lookup>> constructorSupplier =
() -> {

View File

@@ -122,10 +122,11 @@ public class LambdaMessageProcessor implements MessageProcessor<Object>, BeanFac
}
return result;
}
catch (ClassCastException ex) {
logClassCastException(ex);
throw ex;
}
catch (RuntimeException ex) {
if (ex instanceof ClassCastException classCastException) {
logClassCastException(classCastException);
}
throw ex;
}
catch (InvocationTargetException e) {

View File

@@ -1013,13 +1013,6 @@ public class MessagingMethodInvokerHelper extends AbstractExpressionEvaluator im
return null;
}
private static boolean isMethodDefinedOnObjectClass(Method method) {
return method != null && // NOSONAR
(ReflectionUtils.isObjectMethod(method) ||
AopUtils.isFinalizeMethod(method) || (method.getName().equals("clone")
&& method.getParameterTypes().length == 0));
}
public boolean isAsync() {
if (this.handlerMethodsList.size() == 1) {
Method methodToCheck = this.handlerMethodsList.get(0).values().iterator().next().method;