Skip to content

Commit 1134375

Browse files
garyrussellartembilan
authored andcommitted
Sonar Fixes
SMLC major smells
1 parent 30cc3d8 commit 1134375

File tree

12 files changed

+225
-209
lines changed

12 files changed

+225
-209
lines changed

spring-amqp/src/main/java/org/springframework/amqp/AmqpConnectException.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -16,11 +16,9 @@
1616

1717
package org.springframework.amqp;
1818

19-
import java.net.ConnectException;
20-
2119
/**
22-
* RuntimeException wrapper for an {@link ConnectException} which can be commonly thrown from AMQP operations if the
23-
* remote process dies or there is a network issue.
20+
* RuntimeException wrapper for an {@link java.net.ConnectException} which can be commonly
21+
* thrown from AMQP operations if the remote process dies or there is a network issue.
2422
*
2523
* @author Dave Syer
2624
* @author Gary Russell

spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitTemplate.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,9 @@
141141
*
142142
* @since 1.0
143143
*/
144-
public class RabbitTemplate extends RabbitAccessor implements BeanFactoryAware, RabbitOperations, MessageListener,
145-
ListenerContainerAware, PublisherCallbackChannel.Listener, Lifecycle, BeanNameAware {
144+
public class RabbitTemplate extends RabbitAccessor // NOSONAR type line count/comment density
145+
implements BeanFactoryAware, RabbitOperations, MessageListener,
146+
ListenerContainerAware, PublisherCallbackChannel.Listener, Lifecycle, BeanNameAware {
146147

147148
private static final String UNCHECKED = "unchecked";
148149

@@ -2628,4 +2629,4 @@ void returnedMessage(Message message, int replyCode, String replyText,
26282629
String exchange, String routingKey);
26292630
}
26302631

2631-
} // NOSONAR type line count/comment density
2632+
}

spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/MethodRabbitListenerEndpoint.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,25 +159,25 @@ protected MessagingMessageListenerAdapter createMessageListenerInstance() {
159159

160160
@Nullable
161161
private String getDefaultReplyToAddress() {
162-
Method method = getMethod();
163-
if (method != null) {
164-
SendTo ann = AnnotationUtils.getAnnotation(method, SendTo.class);
162+
Method listenerMethod = getMethod();
163+
if (listenerMethod != null) {
164+
SendTo ann = AnnotationUtils.getAnnotation(listenerMethod, SendTo.class);
165165
if (ann != null) {
166166
String[] destinations = ann.value();
167167
if (destinations.length > 1) {
168168
throw new IllegalStateException("Invalid @" + SendTo.class.getSimpleName() + " annotation on '"
169-
+ method + "' one destination must be set (got " + Arrays.toString(destinations) + ")");
169+
+ listenerMethod + "' one destination must be set (got " + Arrays.toString(destinations) + ")");
170170
}
171-
return destinations.length == 1 ? resolve(destinations[0]) : "";
171+
return destinations.length == 1 ? resolveSendTo(destinations[0]) : "";
172172
}
173173
}
174174
return null;
175175
}
176176

177-
private String resolve(String value) {
177+
private String resolveSendTo(String value) {
178178
if (getBeanFactory() != null) {
179-
value = getBeanExpressionContext().getBeanFactory().resolveEmbeddedValue(value);
180-
Object newValue = getResolver().evaluate(value, getBeanExpressionContext());
179+
String resolvedValue = getBeanExpressionContext().getBeanFactory().resolveEmbeddedValue(value);
180+
Object newValue = getResolver().evaluate(resolvedValue, getBeanExpressionContext());
181181
Assert.isInstanceOf(String.class, newValue, "Invalid @SendTo expression");
182182
return (String) newValue;
183183
}

spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/RabbitListenerEndpointRegistry.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
public class RabbitListenerEndpointRegistry implements DisposableBean, SmartLifecycle, ApplicationContextAware,
6868
ApplicationListener<ContextRefreshedEvent> {
6969

70-
protected final Log logger = LogFactory.getLog(getClass());
70+
protected final Log logger = LogFactory.getLog(getClass()); // NOSONAR protected
7171

7272
private final Map<String, MessageListenerContainer> listenerContainers =
7373
new ConcurrentHashMap<String, MessageListenerContainer>();
@@ -256,9 +256,9 @@ public void stop() {
256256

257257
@Override
258258
public void stop(Runnable callback) {
259-
Collection<MessageListenerContainer> listenerContainers = getListenerContainers();
260-
AggregatingCallback aggregatingCallback = new AggregatingCallback(listenerContainers.size(), callback);
261-
for (MessageListenerContainer listenerContainer : listenerContainers) {
259+
Collection<MessageListenerContainer> containers = getListenerContainers();
260+
AggregatingCallback aggregatingCallback = new AggregatingCallback(containers.size(), callback);
261+
for (MessageListenerContainer listenerContainer : containers) {
262262
try {
263263
listenerContainer.stop(aggregatingCallback);
264264
}

0 commit comments

Comments
 (0)