Skip to content

Commit 077eb1d

Browse files
Make pid extraction less dependent on the format
1 parent 21eccc3 commit 077eb1d

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

test/src/com/rabbitmq/tools/Host.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,12 @@ public int getPeerPort() {
133133
public static List<ConnectionInfo> listConnections() throws IOException {
134134
String output = capture(rabbitmqctl("list_connections pid peer_port").getInputStream());
135135
String[] allLines = output.split("\n");
136-
// this pattern must match rabbit_misc:pid_to_string/1
137-
Pattern pattern = Pattern.compile("(<.+\\.\\d+\\.\\d+\\.\\d+>)\\s+(\\d+)");
138136

139137
ArrayList<ConnectionInfo> result = new ArrayList<ConnectionInfo>();
140138
for (String line : Arrays.copyOfRange(allLines, 1, allLines.length - 1)) {
141-
Matcher m = pattern.matcher(line);
142-
m.find();
143-
result.add(new ConnectionInfo(m.group(1), Integer.valueOf(m.group(2))));
139+
// line: <rabbit@mercurio.1.11491.0> 58713
140+
String[] columns = line.split("\t");
141+
result.add(new ConnectionInfo(columns[0], Integer.valueOf(columns[1])));
144142
}
145143
return result;
146144
}

0 commit comments

Comments
 (0)