Skip to content

Commit d31f309

Browse files
committed
More Sonar fixes
1 parent 7084e96 commit d31f309

File tree

15 files changed

+76
-98
lines changed

15 files changed

+76
-98
lines changed

spring-integration-core/src/main/java/org/springframework/integration/config/AbstractMethodAnnotationPostProcessor.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,15 @@ public void processBeanDefinition(String beanName, AnnotatedBeanDefinition beanD
187187

188188
BeanDefinition handlerBeanDefinition =
189189
resolveHandlerBeanDefinition(beanName, beanDefinition, handlerBeanType, annotations);
190-
MergedAnnotations mergedAnnotations = beanDefinition.getFactoryMethodMetadata().getAnnotations();
190+
MergedAnnotations mergedAnnotations =
191+
beanDefinition.getFactoryMethodMetadata().getAnnotations(); // NOSONAR
191192

192193
if (handlerBeanDefinition != null) {
193-
if (handlerBeanDefinition != beanDefinition) {
194+
if (!handlerBeanDefinition.equals(beanDefinition)) {
195+
String beanClassName = handlerBeanDefinition.getBeanClassName();
196+
Assert.notNull(beanClassName, "No bean class present for " + handlerBeanDefinition);
194197
Class<?> handlerBeanClass =
195-
org.springframework.util.ClassUtils.resolveClassName(handlerBeanDefinition.getBeanClassName(),
198+
org.springframework.util.ClassUtils.resolveClassName(beanClassName,
196199
this.beanFactory.getBeanClassLoader());
197200

198201
if (isClassIn(handlerBeanClass, Orderable.class, AbstractSimpleMessageHandlerFactoryBean.class)) {
@@ -381,6 +384,7 @@ private ResolvableType getHandlerBeanClass(AnnotatedBeanDefinition beanDefinitio
381384
return ResolvableType.forMethodReturnType(standardMethodMetadata.getIntrospectedMethod());
382385
}
383386
else {
387+
Assert.notNull(factoryMethodMetadata, "No factoryMethodMetadata present for " + beanDefinition);
384388
String typeName = factoryMethodMetadata.getReturnTypeName();
385389
Class<?> beanClass =
386390
org.springframework.util.ClassUtils.resolveClassName(typeName,

spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationContextUtils.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616

1717
package org.springframework.integration.context;
1818

19-
import org.apache.commons.logging.Log;
20-
import org.apache.commons.logging.LogFactory;
21-
2219
import org.springframework.beans.factory.BeanFactory;
2320
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
2421
import org.springframework.beans.factory.config.BeanDefinition;
@@ -90,8 +87,6 @@ public abstract class IntegrationContextUtils {
9087

9188
public static final String GLOBAL_CHANNEL_INTERCEPTOR_PROCESSOR_BEAN_NAME = "globalChannelInterceptorProcessor";
9289

93-
public static final String JSON_NODE_WRAPPER_TO_JSON_NODE_CONVERTER = "jsonNodeWrapperToJsonNodeConverter";
94-
9590
public static final String INTEGRATION_LIFECYCLE_ROLE_CONTROLLER = "integrationLifecycleRoleController";
9691

9792
public static final String INTEGRATION_GRAPH_SERVER_BEAN_NAME = "integrationGraphServer";
@@ -106,8 +101,6 @@ public abstract class IntegrationContextUtils {
106101

107102
public static final String LIST_MESSAGE_HANDLER_FACTORY_BEAN_NAME = "integrationListMessageHandlerMethodFactory";
108103

109-
private static final Log LOGGER = LogFactory.getLog(IntegrationContextUtils.class);
110-
111104
/**
112105
* @param beanFactory BeanFactory for lookup, must not be null.
113106
* @return The {@link MetadataStore} bean whose name is "metadataStore".

spring-integration-core/src/main/java/org/springframework/integration/dispatcher/AggregateMessageDeliveryException.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -61,7 +61,9 @@ public String getMessage() {
6161
StringBuilder message = new StringBuilder(appendPeriodIfNecessary(baseMessage))
6262
.append(" Multiple causes:\n");
6363
for (Exception exception : this.aggregatedExceptions) {
64-
message.append(" " + exception.getMessage() + "\n");
64+
message.append(" ")
65+
.append(exception.getMessage())
66+
.append("\n");
6567
}
6668
message.append("See below for the stacktrace of the first cause.");
6769
return message.toString();

spring-integration-core/src/main/java/org/springframework/integration/dsl/Pollers.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static PollerSpec fixedRate(Duration period) {
5353
/**
5454
* @deprecated since 6.0 in favor of {@link #fixedRate(Duration)}
5555
*/
56-
@Deprecated(since = "6.0", forRemoval = true)
56+
@Deprecated(forRemoval = true)
5757
public static PollerSpec fixedRate(long period, TimeUnit timeUnit) {
5858
return fixedRate(Duration.of(period, timeUnit.toChronoUnit()));
5959
}
@@ -69,7 +69,7 @@ public static PollerSpec fixedRate(long period, long initialDelay) {
6969
/**
7070
* @deprecated since 6.0 in favor of {@link #fixedRate(Duration, Duration)}
7171
*/
72-
@Deprecated(since = "6.0", forRemoval = true)
72+
@Deprecated(forRemoval = true)
7373
public static PollerSpec fixedRate(long period, TimeUnit timeUnit, long initialDelay) {
7474
ChronoUnit chronoUnit = timeUnit.toChronoUnit();
7575
return fixedRate(Duration.of(period, chronoUnit), Duration.of(initialDelay, chronoUnit));
@@ -90,7 +90,7 @@ public static PollerSpec fixedDelay(Duration period, Duration initialDelay) {
9090
/**
9191
* @deprecated since 6.0 in favor of {@link #fixedDelay(Duration)}
9292
*/
93-
@Deprecated(since = "6.0", forRemoval = true)
93+
@Deprecated(forRemoval = true)
9494
public static PollerSpec fixedDelay(long period, TimeUnit timeUnit) {
9595
return fixedDelay(Duration.of(period, timeUnit.toChronoUnit()));
9696
}
@@ -102,7 +102,7 @@ public static PollerSpec fixedDelay(long period, long initialDelay) {
102102
/**
103103
* @deprecated since 6.0 in favor of {@link #fixedDelay(Duration, Duration)}
104104
*/
105-
@Deprecated(since = "6.0", forRemoval = true)
105+
@Deprecated(forRemoval = true)
106106
public static PollerSpec fixedDelay(long period, TimeUnit timeUnit, long initialDelay) {
107107
ChronoUnit chronoUnit = timeUnit.toChronoUnit();
108108
return fixedDelay(Duration.of(period, chronoUnit), Duration.of(initialDelay, chronoUnit));

spring-integration-core/src/main/java/org/springframework/integration/gateway/DefaultMethodInvokingMethodInterceptor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
/**
3838
* Method interceptor to invoke default methods on the gateway proxy.
39-
*
39+
* <p>
4040
* The copy of {@code DefaultMethodInvokingMethodInterceptor} from Spring Data Commons.
4141
*
4242
* @author Oliver Gierke
@@ -122,7 +122,7 @@ private Lookup getLookup(Class<?> declaringClass, Method privateLookupIn) {
122122

123123
private volatile boolean constructorResolved;
124124

125-
private Constructor<Lookup> constructor;
125+
private transient Constructor<Lookup> constructor;
126126

127127
private final Supplier<Constructor<Lookup>> constructorSupplier =
128128
() -> {

spring-integration-core/src/main/java/org/springframework/integration/handler/LambdaMessageProcessor.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,11 @@ public Object processMessage(Message<?> message) {
122122
}
123123
return result;
124124
}
125+
catch (ClassCastException ex) {
126+
logClassCastException(ex);
127+
throw ex;
128+
}
125129
catch (RuntimeException ex) {
126-
if (ex instanceof ClassCastException classCastException) {
127-
logClassCastException(classCastException);
128-
}
129130
throw ex;
130131
}
131132
catch (InvocationTargetException e) {

spring-integration-core/src/main/java/org/springframework/integration/handler/support/MessagingMethodInvokerHelper.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,13 +1013,6 @@ private HandlerMethod findClosestMatch(Class<?> payloadType) {
10131013
return null;
10141014
}
10151015

1016-
private static boolean isMethodDefinedOnObjectClass(Method method) {
1017-
return method != null && // NOSONAR
1018-
(ReflectionUtils.isObjectMethod(method) ||
1019-
AopUtils.isFinalizeMethod(method) || (method.getName().equals("clone")
1020-
&& method.getParameterTypes().length == 0));
1021-
}
1022-
10231016
public boolean isAsync() {
10241017
if (this.handlerMethodsList.size() == 1) {
10251018
Method methodToCheck = this.handlerMethodsList.get(0).values().iterator().next().method;

spring-integration-groovy/src/main/java/org/springframework/integration/groovy/GroovyScriptExecutingMessageProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -70,7 +70,7 @@ public class GroovyScriptExecutingMessageProcessor extends AbstractScriptExecuti
7070

7171
private final Lock scriptLock = new ReentrantLock();
7272

73-
private ScriptSource scriptSource;
73+
private final ScriptSource scriptSource;
7474

7575
private GroovyClassLoader groovyClassLoader = new GroovyClassLoader(ClassUtils.getDefaultClassLoader());
7676

spring-integration-hazelcast/src/main/java/org/springframework/integration/hazelcast/HazelcastLocalInstanceRegistrar.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2019 the original author or authors.
2+
* Copyright 2015-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -82,9 +82,9 @@ public HazelcastLocalInstanceRegistrar(HazelcastInstance hazelcastInstance) {
8282
public void afterSingletonsInstantiated() {
8383
if (this.hazelcastInstance == null) {
8484
if (!Hazelcast.getAllHazelcastInstances().isEmpty()) {
85-
HazelcastInstance hazelcastInstance = Hazelcast.getAllHazelcastInstances().iterator().next();
86-
hazelcastInstance.getCluster().addMembershipListener(new HazelcastMembershipListener());
87-
syncConfigurationMultiMap(hazelcastInstance);
85+
HazelcastInstance anyHazelcastInstance = Hazelcast.getAllHazelcastInstances().iterator().next();
86+
anyHazelcastInstance.getCluster().addMembershipListener(new HazelcastMembershipListener());
87+
syncConfigurationMultiMap(anyHazelcastInstance);
8888
}
8989
else {
9090
logger.warn("No HazelcastInstances for MembershipListener registration");

spring-integration-hazelcast/src/main/java/org/springframework/integration/hazelcast/inbound/AbstractHazelcastMessageProducer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ protected Set<String> getCacheEvents() {
7373
}
7474

7575
public void setCacheEventTypes(String cacheEventTypes) {
76-
Set<String> cacheEvents =
76+
Set<String> events =
7777
HazelcastIntegrationDefinitionValidator.validateEnumType(CacheEventType.class, cacheEventTypes);
78-
Assert.notEmpty(cacheEvents, "'cacheEvents' must have elements");
78+
Assert.notEmpty(events, "'events' must have elements");
7979
HazelcastIntegrationDefinitionValidator.validateCacheEventsByDistributedObject(this.distributedObject,
80-
cacheEvents);
81-
this.cacheEvents = cacheEvents;
80+
events);
81+
this.cacheEvents = events;
8282
}
8383

8484
protected CacheListeningPolicyType getCacheListeningPolicy() {

0 commit comments

Comments
 (0)