Skip to content

Commit c5923a6

Browse files
committed
Fix some Sonar warnings
(cherry picked from commit c176ff9) Conflicts: src/main/java/com/rabbitmq/client/impl/WorkPool.java
1 parent 6654666 commit c5923a6

File tree

8 files changed

+11
-8
lines changed

8 files changed

+11
-8
lines changed

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); //NOSONAR
1157+
AutorecoveringConnection conn = new AutorecoveringConnection(params, fhFactory, addressResolver, metricsCollector);
11581158

11591159
conn.init();
11601160
return conn;

src/main/java/com/rabbitmq/client/impl/AMQChannel.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,9 @@ public void quiescingTransmit(AMQCommand c) throws IOException {
389389
while (_blockContent) {
390390
try {
391391
_channelMutex.wait();
392-
} catch (InterruptedException ignored) {}
392+
} catch (InterruptedException ignored) {
393+
Thread.currentThread().interrupt();
394+
}
393395

394396
// This is to catch a situation when the thread wakes up during
395397
// shutdown. Currently, no command that has content is allowed

src/main/java/com/rabbitmq/client/impl/WorkPool.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public void enqueue(BlockingQueue<W> queue, W item) {
7777
throw new WorkPoolFullException("Could not enqueue in work pool after " + queueingTimeout + " ms.");
7878
}
7979
} catch (InterruptedException e) {
80-
Thread.currentThread();
80+
Thread.currentThread().interrupt();
8181
}
8282
}
8383
};

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

Lines changed: 1 addition & 1 deletion
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(); //NOSONAR
85+
channel = SocketChannel.open();
8686
channel.configureBlocking(true);
8787
if(nioParams.getSocketChannelConfigurator() != null) {
8888
nioParams.getSocketChannelConfigurator().configure(channel);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ private void sendWriteRequest(WriteRequest writeRequest) throws IOException {
137137
}
138138
} catch (InterruptedException e) {
139139
LOGGER.warn("Thread interrupted during enqueuing frame in write queue");
140+
Thread.currentThread().interrupt();
140141
}
141142
}
142143

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ private static int retryRead(ReadableByteChannel channel, ByteBuffer buffer) thr
113113
try {
114114
Thread.sleep(100L);
115115
} catch (InterruptedException e) {
116-
// ignore
116+
Thread.currentThread().interrupt();
117117
}
118118
read = NioHelper.read(channel, buffer);
119119
if(read > 0) {

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) //NOSONAR
595+
if (newChannel == null)
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: 2 additions & 2 deletions
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) { //NOSONAR
187+
if (ch == null) {
188188
return null;
189189
} else {
190190
return this.wrapChannel(ch);
@@ -565,7 +565,7 @@ public void removeConsumerRecoveryListener(ConsumerRecoveryListener listener) {
565565
}
566566

567567
private synchronized void beginAutomaticRecovery() throws InterruptedException {
568-
Thread.sleep(this.params.getRecoveryDelayHandler().getDelay(0));
568+
this.wait(this.params.getRecoveryDelayHandler().getDelay(0));
569569

570570
this.notifyRecoveryListenersStarted();
571571

0 commit comments

Comments
 (0)