Skip to content

Commit 1c3cf6a

Browse files
committed
Fix some Sonar warnings
1 parent 666615e commit 1c3cf6a

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
@@ -744,6 +744,17 @@
744744
</dependencies>
745745

746746
<build>
747+
748+
<pluginManagement>
749+
<plugins>
750+
<plugin>
751+
<groupId>org.sonarsource.scanner.maven</groupId>
752+
<artifactId>sonar-maven-plugin</artifactId>
753+
<version>3.5.0.1254</version>
754+
</plugin>
755+
</plugins>
756+
</pluginManagement>
757+
747758
<!-- We store the client version in a Java properties file. -->
748759
<resources>
749760
<resource>

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

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

11001100
if (isAutomaticRecoveryEnabled()) {
11011101
// see com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory#newConnection
1102-
AutorecoveringConnection conn = new AutorecoveringConnection(params, fhFactory, addressResolver, metricsCollector);
1102+
AutorecoveringConnection conn = new AutorecoveringConnection(params, fhFactory, addressResolver, metricsCollector); //NOSONAR
11031103

11041104
conn.init();
11051105
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
@@ -78,7 +78,7 @@ public FrameHandler create(Address addr, String connectionName) throws IOExcepti
7878
}
7979

8080
SocketAddress address = new InetSocketAddress(addr.getHost(), portNumber);
81-
channel = SocketChannel.open();
81+
channel = SocketChannel.open(); //NOSONAR
8282
channel.configureBlocking(true);
8383
if(nioParams.getSocketChannelConfigurator() != null) {
8484
nioParams.getSocketChannelConfigurator().configure(channel);
@@ -122,7 +122,9 @@ public FrameHandler create(Address addr, String connectionName) throws IOExcepti
122122
if(sslEngine != null && channel != null) {
123123
SslEngineHelper.close(channel, sslEngine);
124124
}
125-
channel.close();
125+
if (channel != null) {
126+
channel.close();
127+
}
126128
} catch(IOException closingException) {
127129
// ignore
128130
}

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

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

763763
final RecoveryAwareChannelN newChannel = (RecoveryAwareChannelN) connDelegate.createChannel(this.getChannelNumber());
764-
if (newChannel == null)
764+
if (newChannel == null) //NOSONAR
765765
throw new IOException("Failed to create new channel for channel number=" + this.getChannelNumber() + " during recovery");
766766
newChannel.inheritOffsetFrom(defunctChannel);
767767
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
@@ -163,7 +163,7 @@ public void init() throws IOException, TimeoutException {
163163
@Override
164164
public Channel createChannel() throws IOException {
165165
RecoveryAwareChannelN ch = (RecoveryAwareChannelN) delegate.createChannel();
166-
if (ch == null) {
166+
if (ch == null) { //NOSONAR
167167
return null;
168168
} else {
169169
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)