Skip to content

Commit e2c69b7

Browse files
committed
Fix some Sonar warnings
(cherry picked from commit 1c3cf6a)
1 parent 036db24 commit e2c69b7

File tree

7 files changed

+21
-8
lines changed

7 files changed

+21
-8
lines changed

pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,17 @@
759759
</dependencies>
760760

761761
<build>
762+
763+
<pluginManagement>
764+
<plugins>
765+
<plugin>
766+
<groupId>org.sonarsource.scanner.maven</groupId>
767+
<artifactId>sonar-maven-plugin</artifactId>
768+
<version>3.5.0.1254</version>
769+
</plugin>
770+
</plugins>
771+
</pluginManagement>
772+
762773
<!-- We store the client version in a Java properties file. -->
763774
<resources>
764775
<resource>

src/main/java/com/rabbitmq/client/ConnectionFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ public Connection newConnection(ExecutorService executor, AddressResolver addres
11541154

11551155
if (isAutomaticRecoveryEnabled()) {
11561156
// see com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory#newConnection
1157-
AutorecoveringConnection conn = new AutorecoveringConnection(params, fhFactory, addressResolver, metricsCollector);
1157+
AutorecoveringConnection conn = new AutorecoveringConnection(params, fhFactory, addressResolver, metricsCollector); //NOSONAR
11581158

11591159
conn.init();
11601160
return conn;

src/main/java/com/rabbitmq/client/impl/nio/FrameBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public Frame readFrame() throws IOException {
8080
frameBuffer[0] = readFromBuffer();
8181
} else if (bytesRead == 2) {
8282
// channel 2/2
83-
frameChannel = (frameBuffer[0] << 8) + (readFromBuffer() << 0);
83+
frameChannel = (frameBuffer[0] << 8) + readFromBuffer();
8484
} else if (bytesRead == 3) {
8585
// payload size 1/4
8686
frameBuffer[0] = readFromBuffer();
@@ -92,7 +92,7 @@ public Frame readFrame() throws IOException {
9292
frameBuffer[2] = readFromBuffer();
9393
} else if (bytesRead == 6) {
9494
// payload size 4/4
95-
int framePayloadSize = ((frameBuffer[0] << 24) + (frameBuffer[1] << 16) + (frameBuffer[2] << 8) + (readFromBuffer() << 0));
95+
int framePayloadSize = (frameBuffer[0] << 24) + (frameBuffer[1] << 16) + (frameBuffer[2] << 8) + readFromBuffer();
9696
framePayload = new byte[framePayloadSize];
9797
} else if (bytesRead >= PAYLOAD_OFFSET && bytesRead < framePayload.length + PAYLOAD_OFFSET) {
9898
framePayload[bytesRead - PAYLOAD_OFFSET] = (byte) readFromBuffer();

src/main/java/com/rabbitmq/client/impl/nio/SocketChannelFrameHandlerFactory.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public FrameHandler create(Address addr) throws IOException {
8282
}
8383

8484
SocketAddress address = new InetSocketAddress(addr.getHost(), portNumber);
85-
channel = SocketChannel.open();
85+
channel = SocketChannel.open(); //NOSONAR
8686
channel.configureBlocking(true);
8787
if(nioParams.getSocketChannelConfigurator() != null) {
8888
nioParams.getSocketChannelConfigurator().configure(channel);
@@ -131,7 +131,9 @@ public FrameHandler create(Address addr) throws IOException {
131131
if(sslEngine != null && channel != null) {
132132
SslEngineHelper.close(channel, sslEngine);
133133
}
134-
channel.close();
134+
if (channel != null) {
135+
channel.close();
136+
}
135137
} catch(IOException closingException) {
136138
// ignore
137139
}

src/main/java/com/rabbitmq/client/impl/recovery/AutorecoveringChannel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ public void automaticallyRecover(AutorecoveringConnection connection, Connection
592592
this.connection = connection;
593593

594594
final RecoveryAwareChannelN newChannel = (RecoveryAwareChannelN) connDelegate.createChannel(this.getChannelNumber());
595-
if (newChannel == null)
595+
if (newChannel == null) //NOSONAR
596596
throw new IOException("Failed to create new channel for channel number=" + this.getChannelNumber() + " during recovery");
597597
newChannel.inheritOffsetFrom(defunctChannel);
598598
this.delegate = newChannel;

src/main/java/com/rabbitmq/client/impl/recovery/AutorecoveringConnection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public void init() throws IOException, TimeoutException {
184184
@Override
185185
public Channel createChannel() throws IOException {
186186
RecoveryAwareChannelN ch = (RecoveryAwareChannelN) delegate.createChannel();
187-
if (ch == null) {
187+
if (ch == null) { //NOSONAR
188188
return null;
189189
} else {
190190
return this.wrapChannel(ch);

src/main/java/com/rabbitmq/utility/BlockingCell.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class BlockingCell<T> {
2828
/** Will be null until a value is supplied, and possibly still then. */
2929
private T _value;
3030

31-
private static final long NANOS_IN_MILLI = 1000 * 1000;
31+
private static final long NANOS_IN_MILLI = 1000L * 1000L;
3232

3333
private static final long INFINITY = -1;
3434

0 commit comments

Comments
 (0)