Skip to content

Commit 90e70be

Browse files
Added time to error message when port open timed out.
1 parent 3a35f77 commit 90e70be

File tree

1 file changed

+9
-2
lines changed
  • dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/utils

1 file changed

+9
-2
lines changed

dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/utils/PortUtils.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ private static boolean isPortOpen(String host, int port) {
105105

106106
public static void waitForPortToOpen(
107107
final int port, final long timeout, final TimeUnit unit, final Process process) {
108-
final long waitUntil = System.currentTimeMillis() + unit.toMillis(timeout);
108+
final long startedAt = System.currentTimeMillis();
109+
final long waitUntil = startedAt + unit.toMillis(timeout);
109110

110111
while (System.currentTimeMillis() < waitUntil) {
111112
try {
@@ -133,7 +134,13 @@ public static void waitForPortToOpen(
133134
}
134135
}
135136

136-
throw new RuntimeException("Timed out waiting for port " + port + " to be opened");
137+
throw new RuntimeException(
138+
"Timed out waiting for port "
139+
+ port
140+
+ " to be opened, started to wait at: "
141+
+ startedAt
142+
+ ", timed out at: "
143+
+ System.currentTimeMillis());
137144
}
138145

139146
public static void waitForPortToOpen(String host, int port, long timeout, TimeUnit unit) {

0 commit comments

Comments
 (0)