File tree 1 file changed +9
-1
lines changed
src/test/java/com/rabbitmq/tools
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -239,13 +239,21 @@ public int getPeerPort() {
239
239
240
240
public static List <ConnectionInfo > listConnections () throws IOException {
241
241
String output = capture (rabbitmqctl ("list_connections -q pid peer_port" ).getInputStream ());
242
+ // output (header line presence depends on broker version):
243
+ // pid peer_port
244
+
242
245
String [] allLines = output .split ("\n " );
243
246
244
247
ArrayList <ConnectionInfo > result = new ArrayList <ConnectionInfo >();
245
248
for (String line : allLines ) {
246
249
// line: <[email protected] > 58713
247
250
String [] columns = line .split ("\t " );
248
- result .add (new ConnectionInfo (columns [0 ], Integer .valueOf (columns [1 ])));
251
+ // can be also header line, so ignoring NumberFormatException
252
+ try {
253
+ result .add (new ConnectionInfo (columns [0 ], Integer .valueOf (columns [1 ])));
254
+ } catch (NumberFormatException e ) {
255
+ // OK
256
+ }
249
257
}
250
258
return result ;
251
259
}
You can’t perform that action at this time.
0 commit comments