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