Skip to content

Commit 6ba27ee

Browse files
garyrussellartembilan
authored andcommitted
Sonar Fixes
- all minors * Remaining issues - mostly imports for Javadocs only. * Final final * Polising - bogus chars in comment * Polishing idle time.
1 parent 24521d8 commit 6ba27ee

File tree

56 files changed

+279
-254
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+279
-254
lines changed

spring-amqp/src/main/java/org/springframework/amqp/core/Address.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public class Address {
4848
*/
4949
public static final String AMQ_RABBITMQ_REPLY_TO = "amq.rabbitmq.reply-to";
5050

51-
private static final Pattern pattern = Pattern.compile("^(?:.*://)?([^/]*)/?(.*)$");
51+
private static final Pattern ADDRESS_PATTERN = Pattern.compile("^(?:.*://)?([^/]*)/?(.*)$");
5252

5353
private final String exchangeName;
5454

@@ -77,7 +77,7 @@ else if (address.lastIndexOf('/') <= 0) {
7777
this.exchangeName = "";
7878
}
7979
else {
80-
Matcher matcher = pattern.matcher(address);
80+
Matcher matcher = ADDRESS_PATTERN.matcher(address);
8181
boolean matchFound = matcher.find();
8282
if (matchFound) {
8383
this.exchangeName = matcher.group(1);
@@ -131,7 +131,8 @@ public boolean equals(Object o) {
131131
@Override
132132
public int hashCode() {
133133
int result = this.exchangeName != null ? this.exchangeName.hashCode() : 0;
134-
result = 31 * result + (this.routingKey != null ? this.routingKey.hashCode() : 0);
134+
int prime = 31; // NOSONAR magic #
135+
result = prime * result + (this.routingKey != null ? this.routingKey.hashCode() : 0);
135136
return result;
136137
}
137138

spring-amqp/src/main/java/org/springframework/amqp/core/AmqpTemplate.java

Lines changed: 4 additions & 4 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.
@@ -17,7 +17,6 @@
1717
package org.springframework.amqp.core;
1818

1919
import org.springframework.amqp.AmqpException;
20-
import org.springframework.amqp.support.converter.MessageConverter;
2120
import org.springframework.core.ParameterizedTypeReference;
2221
import org.springframework.lang.Nullable;
2322

@@ -26,8 +25,9 @@
2625
*
2726
* Provides synchronous send and receive methods. The {@link #convertAndSend(Object)} and
2827
* {@link #receiveAndConvert()} methods allow let you send and receive POJO objects.
29-
* Implementations are expected to delegate to an instance of {@link MessageConverter} to
30-
* perform conversion to and from AMQP byte[] payload type.
28+
* Implementations are expected to delegate to an instance of
29+
* {@link org.springframework.amqp.support.converter.MessageConverter} to perform
30+
* conversion to and from AMQP byte[] payload type.
3131
*
3232
* @author Mark Pollack
3333
* @author Mark Fisher

spring-amqp/src/main/java/org/springframework/amqp/core/AnonymousQueue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public Base64UrlNamingStrategy(String prefix) {
150150
@Override
151151
public String generateName() {
152152
UUID uuid = UUID.randomUUID();
153-
ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
153+
ByteBuffer bb = ByteBuffer.wrap(new byte[16]); // NOSONAR - Magic # deprecated anyway
154154
bb.putLong(uuid.getMostSignificantBits())
155155
.putLong(uuid.getLeastSignificantBits());
156156
// Convert to base64 and remove trailing =

spring-amqp/src/main/java/org/springframework/amqp/core/Base64UrlNamingStrategy.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
*/
3535
public class Base64UrlNamingStrategy implements NamingStrategy {
3636

37+
private static final int SIXTEEN = 16;
38+
3739
/**
3840
* The default instance - using {@code spring.gen-} as the prefix.
3941
*/
@@ -60,7 +62,7 @@ public Base64UrlNamingStrategy(String prefix) {
6062
@Override
6163
public String generateName() {
6264
UUID uuid = UUID.randomUUID();
63-
ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
65+
ByteBuffer bb = ByteBuffer.wrap(new byte[SIXTEEN]);
6466
bb.putLong(uuid.getMostSignificantBits())
6567
.putLong(uuid.getLeastSignificantBits());
6668
// Convert to base64 and remove trailing =

spring-amqp/src/main/java/org/springframework/amqp/core/MessageProperties.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
*/
3636
public class MessageProperties implements Serializable {
3737

38+
private static final int INT_MASK = 32;
39+
3840
private static final long serialVersionUID = 1619000546531112290L;
3941

4042
public static final String CONTENT_TYPE_BYTES = "application/octet-stream";
@@ -123,11 +125,11 @@ public class MessageProperties implements Serializable {
123125

124126
private volatile long publishSequenceNumber;
125127

126-
private volatile transient Type inferredArgumentType;
128+
private transient volatile Type inferredArgumentType;
127129

128-
private volatile transient Method targetMethod;
130+
private transient volatile Method targetMethod;
129131

130-
private volatile transient Object targetBean;
132+
private transient volatile Object targetBean;
131133

132134
public void setHeader(String key, Object value) {
133135
this.headers.put(key, value);
@@ -538,11 +540,11 @@ public int hashCode() {
538540
result = prime * result + ((this.appId == null) ? 0 : this.appId.hashCode());
539541
result = prime * result + ((this.clusterId == null) ? 0 : this.clusterId.hashCode());
540542
result = prime * result + ((this.contentEncoding == null) ? 0 : this.contentEncoding.hashCode());
541-
result = prime * result + (int) (this.contentLength ^ (this.contentLength >>> 32));
543+
result = prime * result + (int) (this.contentLength ^ (this.contentLength >>> INT_MASK));
542544
result = prime * result + ((this.contentType == null) ? 0 : this.contentType.hashCode());
543545
result = prime * result + this.correlationId.hashCode();
544546
result = prime * result + ((this.deliveryMode == null) ? 0 : this.deliveryMode.hashCode());
545-
result = prime * result + (int) (this.deliveryTag ^ (this.deliveryTag >>> 32));
547+
result = prime * result + (int) (this.deliveryTag ^ (this.deliveryTag >>> INT_MASK));
546548
result = prime * result + ((this.expiration == null) ? 0 : this.expiration.hashCode());
547549
result = prime * result + this.headers.hashCode();
548550
result = prime * result + ((this.messageCount == null) ? 0 : this.messageCount.hashCode());

spring-amqp/src/main/java/org/springframework/amqp/core/QueueBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*/
2828
public final class QueueBuilder extends AbstractBuilder {
2929

30-
private static final NamingStrategy namingStrategy = Base64UrlNamingStrategy.DEFAULT;
30+
private static final NamingStrategy namingStrategy = Base64UrlNamingStrategy.DEFAULT; // NOSONAR lower case
3131

3232
private final String name;
3333

spring-amqp/src/main/java/org/springframework/amqp/remoting/client/AmqpClientInterceptor.java

Lines changed: 2 additions & 3 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.
@@ -22,7 +22,6 @@
2222
import org.aopalliance.intercept.MethodInvocation;
2323

2424
import org.springframework.amqp.core.AmqpTemplate;
25-
import org.springframework.amqp.remoting.service.AmqpInvokerServiceExporter;
2625
import org.springframework.remoting.RemoteProxyFailureException;
2726
import org.springframework.remoting.support.DefaultRemoteInvocationFactory;
2827
import org.springframework.remoting.support.RemoteAccessor;
@@ -36,7 +35,7 @@
3635
* @author David Bilge
3736
* @author Gary Russell
3837
* @since 1.2
39-
* @see AmqpInvokerServiceExporter
38+
* @see org.springframework.amqp.remoting.service.AmqpInvokerServiceExporter
4039
* @see AmqpProxyFactoryBean
4140
* @see org.springframework.remoting.RemoteAccessException
4241
*/

spring-amqp/src/main/java/org/springframework/amqp/remoting/client/AmqpProxyFactoryBean.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,10 @@
1616

1717
package org.springframework.amqp.remoting.client;
1818

19-
import org.springframework.amqp.core.AmqpTemplate;
20-
import org.springframework.amqp.remoting.service.AmqpInvokerServiceExporter;
2119
import org.springframework.aop.framework.ProxyFactory;
2220
import org.springframework.beans.factory.BeanClassLoaderAware;
2321
import org.springframework.beans.factory.FactoryBean;
2422
import org.springframework.beans.factory.InitializingBean;
25-
import org.springframework.remoting.rmi.RmiServiceExporter;
2623

2724
/**
2825
* {@link FactoryBean} for AMQP proxies. Exposes the proxied service for use as a bean reference, using the specified
@@ -32,16 +29,17 @@
3229
* This is intended for an "RMI-style" (i.e. synchroneous) usage of the AMQP protocol. Obviously, AMQP allows for a much
3330
* broader scope of execution styles, which are not the scope of the mechanism at hand.
3431
* <p>
35-
* Calling a method on the proxy will cause an AMQP message being sent according to the configured {@link AmqpTemplate}.
36-
* This can be received and answered by an {@link AmqpInvokerServiceExporter}.
32+
* Calling a method on the proxy will cause an AMQP message being sent according to the configured
33+
* {@link org.springframework.amqp.core.AmqpTemplate}.
34+
* This can be received and answered by an {@link org.springframework.amqp.remoting.service.AmqpInvokerServiceExporter}.
3735
*
3836
* @author David Bilge
3937
* @author Gary Russell
4038
*
4139
* @since 1.2
4240
* @see #setServiceInterface
4341
* @see AmqpClientInterceptor
44-
* @see RmiServiceExporter
42+
* @see org.springframework.remoting.rmi.RmiServiceExporter
4543
* @see org.springframework.remoting.RemoteAccessException
4644
*/
4745
public class AmqpProxyFactoryBean extends AmqpClientInterceptor implements FactoryBean<Object>, BeanClassLoaderAware,

spring-amqp/src/main/java/org/springframework/amqp/remoting/service/AmqpInvokerServiceExporter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.springframework.amqp.core.Message;
2323
import org.springframework.amqp.core.MessageListener;
2424
import org.springframework.amqp.core.MessageProperties;
25-
import org.springframework.amqp.remoting.client.AmqpProxyFactoryBean;
2625
import org.springframework.amqp.support.converter.MessageConverter;
2726
import org.springframework.amqp.support.converter.SimpleMessageConverter;
2827
import org.springframework.remoting.support.RemoteInvocation;
@@ -31,7 +30,7 @@
3130

3231
/**
3332
* This message listener exposes a plain java service via AMQP. Such services can be accessed via plain AMQP or via
34-
* {@link AmqpProxyFactoryBean}.
33+
* {@link org.springframework.amqp.remoting.client.AmqpProxyFactoryBean}.
3534
*
3635
* To configure this message listener so that it actually receives method calls via AMQP, it needs to be put into a
3736
* listener container. See {@link MessageListener}.

spring-amqp/src/main/java/org/springframework/amqp/support/AmqpHeaders.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public abstract class AmqpHeaders {
6565

6666
public static final String RECEIVED_DELAY = PREFIX + "receivedDelay";
6767

68-
public final static String RECEIVED_DELIVERY_MODE = PREFIX + "receivedDeliveryMode";
68+
public static final String RECEIVED_DELIVERY_MODE = PREFIX + "receivedDeliveryMode";
6969

7070
public static final String RECEIVED_EXCHANGE = PREFIX + "receivedExchange";
7171

0 commit comments

Comments
 (0)