Skip to content

Commit 6a6b26c

Browse files
AMQConnection: squash a few more IDEA warnings
1 parent 8fa6760 commit 6a6b26c

File tree

1 file changed

+18
-23
lines changed

1 file changed

+18
-23
lines changed

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

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class AMQConnection extends ShutdownNotifierComponent implements Connecti
5050
private static final Logger LOGGER = LoggerFactory.getLogger(AMQConnection.class);
5151
// we want socket write and channel shutdown timeouts to kick in after
5252
// the heartbeat one, so we use a value of 105% of the effective heartbeat timeout
53-
public static final double CHANNEL_SHUTDOWN_TIMEOUT_MULTIPLIER = 1.05;
53+
static final double CHANNEL_SHUTDOWN_TIMEOUT_MULTIPLIER = 1.05;
5454

5555
private final ExecutorService consumerWorkServiceExecutor;
5656
private final ScheduledExecutorService heartbeatExecutor;
@@ -60,7 +60,7 @@ public class AMQConnection extends ShutdownNotifierComponent implements Connecti
6060
private String id;
6161

6262
private final List<RecoveryCanBeginListener> recoveryCanBeginListeners =
63-
Collections.synchronizedList(new ArrayList<RecoveryCanBeginListener>());
63+
Collections.synchronizedList(new ArrayList<>());
6464

6565
private final ErrorOnWriteListener errorOnWriteListener;
6666

@@ -77,14 +77,14 @@ public class AMQConnection extends ShutdownNotifierComponent implements Connecti
7777
* @see Connection#getClientProperties
7878
*/
7979
public static Map<String, Object> defaultClientProperties() {
80-
Map<String,Object> props = new HashMap<String, Object>();
80+
Map<String,Object> props = new HashMap<>();
8181
props.put("product", LongStringHelper.asLongString("RabbitMQ"));
8282
props.put("version", LongStringHelper.asLongString(ClientVersion.VERSION));
8383
props.put("platform", LongStringHelper.asLongString("Java"));
8484
props.put("copyright", LongStringHelper.asLongString(Copyright.COPYRIGHT));
8585
props.put("information", LongStringHelper.asLongString(Copyright.LICENSE));
8686

87-
Map<String, Object> capabilities = new HashMap<String, Object>();
87+
Map<String, Object> capabilities = new HashMap<>();
8888
capabilities.put("publisher_confirms", true);
8989
capabilities.put("exchange_exchange_bindings", true);
9090
capabilities.put("basic.nack", true);
@@ -117,7 +117,7 @@ public static Map<String, Object> defaultClientProperties() {
117117
/** Object used for blocking main application thread when doing all the necessary
118118
* connection shutdown operations
119119
*/
120-
private final BlockingCell<Object> _appContinuation = new BlockingCell<Object>();
120+
private final BlockingCell<Object> _appContinuation = new BlockingCell<>();
121121

122122
/** Flag indicating whether the client received Connection.Close message from the broker */
123123
private volatile boolean _brokerInitiatedShutdown;
@@ -137,7 +137,7 @@ public static Map<String, Object> defaultClientProperties() {
137137
private final int handshakeTimeout;
138138
private final int shutdownTimeout;
139139
private final CredentialsProvider credentialsProvider;
140-
private final Collection<BlockedListener> blockedListeners = new CopyOnWriteArrayList<BlockedListener>();
140+
private final Collection<BlockedListener> blockedListeners = new CopyOnWriteArrayList<>();
141141
protected final MetricsCollector metricsCollector;
142142
private final int channelRpcTimeout;
143143
private final boolean channelShouldCheckRpcResponseType;
@@ -157,10 +157,10 @@ public static Map<String, Object> defaultClientProperties() {
157157
private volatile Map<String, Object> _serverProperties;
158158

159159
/**
160-
* Protected API - respond, in the driver thread, to a ShutdownSignal.
160+
* Protected API - respond, in the main I/O loop thread, to a ShutdownSignal.
161161
* @param channel the channel to disconnect
162162
*/
163-
public final void disconnectChannel(ChannelN channel) {
163+
final void disconnectChannel(ChannelN channel) {
164164
ChannelManager cm = _channelManager;
165165
if (cm != null)
166166
cm.releaseChannelNumber(channel);
@@ -367,15 +367,12 @@ public void start()
367367
throw new PossibleAuthenticationFailureException(e);
368368
}
369369
} while (connTune == null);
370-
} catch (TimeoutException te) {
370+
} catch (TimeoutException | IOException te) {
371371
_frameHandler.close();
372372
throw te;
373373
} catch (ShutdownSignalException sse) {
374374
_frameHandler.close();
375375
throw AMQChannel.wrap(sse);
376-
} catch(IOException ioe) {
377-
_frameHandler.close();
378-
throw ioe;
379376
}
380377

381378
try {
@@ -509,7 +506,7 @@ public ThreadFactory getThreadFactory() {
509506

510507
@Override
511508
public Map<String, Object> getClientProperties() {
512-
return new HashMap<String, Object>(_clientProperties);
509+
return new HashMap<>(_clientProperties);
513510
}
514511

515512
@Override
@@ -560,7 +557,7 @@ public Channel createChannel() throws IOException {
560557
/**
561558
* Public API - sends a frame directly to the broker.
562559
*/
563-
public void writeFrame(Frame f) throws IOException {
560+
void writeFrame(Frame f) throws IOException {
564561
_frameHandler.writeFrame(f);
565562
_heartbeatSender.signalActivity();
566563
}
@@ -755,6 +752,7 @@ public void addRecoveryCanBeginListener(RecoveryCanBeginListener fn) {
755752
this.recoveryCanBeginListeners.add(fn);
756753
}
757754

755+
@SuppressWarnings("unused")
758756
public void removeRecoveryCanBeginListener(RecoveryCanBeginListener fn) {
759757
this.recoveryCanBeginListeners.remove(fn);
760758
}
@@ -842,7 +840,7 @@ public boolean processControlCommand(Command c) throws IOException
842840
}
843841
}
844842

845-
public void handleConnectionClose(Command closeCommand) {
843+
private void handleConnectionClose(Command closeCommand) {
846844
ShutdownSignalException sse = shutdown(closeCommand.getMethod(), false, null, _inConnectionNegotiation);
847845
try {
848846
_channel0.quiescingTransmit(new AMQP.Connection.CloseOk.Builder().build());
@@ -863,13 +861,13 @@ public void handleConnectionClose(Command closeCommand) {
863861
}
864862
}
865863

866-
// same as ConnectionFactory.DEFAULT_SHUTDOWN_TIMEOUT
867-
private static long SOCKET_CLOSE_TIMEOUT = 10000;
868-
869864
private class SocketCloseWait implements Runnable {
865+
// same as ConnectionFactory.DEFAULT_SHUTDOWN_TIMEOUT
866+
private long SOCKET_CLOSE_TIMEOUT = 10000;
867+
870868
private final ShutdownSignalException cause;
871869

872-
public SocketCloseWait(ShutdownSignalException sse) {
870+
SocketCloseWait(ShutdownSignalException sse) {
873871
cause = sse;
874872
}
875873

@@ -1055,12 +1053,9 @@ public AMQCommand transformReply(AMQCommand command) {
10551053
sse.initCause(cause);
10561054
throw sse;
10571055
}
1058-
} catch (ShutdownSignalException sse) {
1056+
} catch (ShutdownSignalException | IOException sse) {
10591057
if (!abort)
10601058
throw sse;
1061-
} catch (IOException ioe) {
1062-
if (!abort)
1063-
throw ioe;
10641059
} finally {
10651060
if(sync) _frameHandler.close();
10661061
}

0 commit comments

Comments
 (0)