Skip to content

Commit 844fa24

Browse files
committed
Fallback to hostname command to check hostname
In metadata test, to make new CI happy.
1 parent 3d48a72 commit 844fa24

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ private static Process executeCommand(String command) throws IOException {
5555
return pr;
5656
}
5757

58+
public static String hostname() throws IOException {
59+
Process process = executeCommand("hostname");
60+
return capture(process.getInputStream()).trim();
61+
}
62+
5863
private static int waitForExitValue(Process pr) {
5964
while (true) {
6065
try {

src/test/java/com/rabbitmq/stream/impl/MetadataTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.rabbitmq.stream.Constants;
2121
import com.rabbitmq.stream.Host;
2222
import com.rabbitmq.stream.impl.Client.Broker;
23+
import java.io.IOException;
2324
import java.net.InetAddress;
2425
import java.net.UnknownHostException;
2526
import java.util.*;
@@ -144,7 +145,11 @@ static String hostname() {
144145
try {
145146
return InetAddress.getLocalHost().getHostName();
146147
} catch (UnknownHostException e) {
147-
throw new RuntimeException(e);
148+
try {
149+
return Host.hostname();
150+
} catch (IOException ex) {
151+
throw new RuntimeException(ex);
152+
}
148153
}
149154
}
150155
}

0 commit comments

Comments
 (0)