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() {
242242
243243 public static List <ConnectionInfo > listConnections () throws IOException {
244244 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+ 245248 String [] allLines = output .split ("\n " );
246249
247250 ArrayList <ConnectionInfo > result = new ArrayList <ConnectionInfo >();
248251 for (String line : allLines ) {
249252 // line: <[email protected] > 58713 250253 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+ }
252260 }
253261 return result ;
254262 }
You can’t perform that action at this time.
0 commit comments