Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.

Commit 46c4469

Browse files
committed
Ignore header line in rabbitmqctl output
For tests.
1 parent b99e541 commit 46c4469

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/test/java/reactor/rabbitmq/Host.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,21 @@ public static void closeConnection(NetworkConnection c) throws IOException {
101101

102102
public static List<ConnectionInfo> listConnections() throws IOException {
103103
String output = capture(rabbitmqctl("list_connections -q pid peer_port").getInputStream());
104+
// output (header line presence depends on broker version):
105+
// pid peer_port
106+
// <[email protected]> 58713
104107
String[] allLines = output.split("\n");
105108

106109
ArrayList<ConnectionInfo> result = new ArrayList<ConnectionInfo>();
107110
for (String line : allLines) {
108111
// line: <[email protected]> 58713
109112
String[] columns = line.split("\t");
110-
result.add(new ConnectionInfo(columns[0], Integer.valueOf(columns[1])));
113+
// can be also header line, so ignoring NumberFormatException
114+
try {
115+
result.add(new ConnectionInfo(columns[0], Integer.valueOf(columns[1])));
116+
} catch (NumberFormatException e) {
117+
// OK
118+
}
111119
}
112120
return result;
113121
}

0 commit comments

Comments
 (0)