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 @@ -239,13 +239,21 @@ public int getPeerPort() {
239239
240240 public static List <ConnectionInfo > listConnections () throws IOException {
241241 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+ // <rabbit@mercurio.1.11491.0> 58713
242245 String [] allLines = output .split ("\n " );
243246
244247 ArrayList <ConnectionInfo > result = new ArrayList <ConnectionInfo >();
245248 for (String line : allLines ) {
246249 // line: <rabbit@mercurio.1.11491.0> 58713
247250 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+ }
249257 }
250258 return result ;
251259 }
You can’t perform that action at this time.
0 commit comments