Skip to content

Commit c858623

Browse files
committed
Ignore header line in rabbitmqctl output
For tests.
1 parent d453ba0 commit c858623

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/test/java/com/rabbitmq/perf/it/Host.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,21 @@ public static void closeAllConnections() throws IOException {
113113

114114
public static List<ConnectionInfo> listConnections() throws IOException {
115115
String output = capture(rabbitmqctl("list_connections -q pid peer_port").getInputStream());
116+
// output (header line presence depends on broker version):
117+
// pid peer_port
118+
// <[email protected]> 58713
116119
String[] allLines = output.split("\n");
117120

118121
ArrayList<ConnectionInfo> result = new ArrayList<ConnectionInfo>();
119122
for (String line : allLines) {
120123
// line: <[email protected]> 58713
121124
String[] columns = line.split("\t");
122-
result.add(new ConnectionInfo(columns[0], Integer.valueOf(columns[1])));
125+
// can be also header line, so ignoring NumberFormatException
126+
try {
127+
result.add(new ConnectionInfo(columns[0], Integer.valueOf(columns[1])));
128+
} catch (NumberFormatException e) {
129+
// OK
130+
}
123131
}
124132
return result;
125133
}

0 commit comments

Comments
 (0)