Skip to content

Commit 7d79d9b

Browse files
committed
Debug port can be still unbindable after previous JVM died
Signed-off-by: David Matějček <[email protected]>
1 parent f103aa2 commit 7d79d9b

File tree

2 files changed

+3
-7
lines changed
  • appserver/itest-tools/src/main/java/org/glassfish/main/itest/tools/asadmin
  • nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli

2 files changed

+3
-7
lines changed

appserver/itest-tools/src/main/java/org/glassfish/main/itest/tools/asadmin/Asadmin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ private File getPasswordFile() {
242242
*/
243243
private AsadminResult exec(final Integer timeout, final boolean detachedAndTerse, final String... args) {
244244
final List<String> parameters = Arrays.asList(args);
245-
LOG.log(TRACE, "exec(timeout={0}, detached={1}, args={2})", timeout, detachedAndTerse, parameters);
245+
LOG.log(INFO, "exec(timeout={0}, detached={1}, args={2})", timeout, detachedAndTerse, parameters);
246246
final List<String> command = new ArrayList<>();
247247
if (asadmin.getName().endsWith(".java")) {
248248
command.add(JAVA_EXECUTABLE);

nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartServerHelper.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,14 +277,10 @@ public static List<HostAndPort> parseCustomEndpoints(String customEndpoints) thr
277277
* So we have to wait a bit.
278278
*/
279279
private static void checkFreeDebugPort(Integer debugPort, Duration timeout, boolean terse) {
280-
if (debugPort == null) {
280+
if (debugPort == null || NetUtils.isPortFree(debugPort)) {
281281
return;
282282
}
283-
final HostAndPort debugEndpoint = new HostAndPort("localhost", debugPort, false);
284-
if (!ProcessUtils.isListening(debugEndpoint)) {
285-
return;
286-
}
287-
ProcessUtils.waitWhileListening(debugEndpoint, timeout, !terse);
283+
ProcessUtils.waitFor(() -> NetUtils.isPortFree(debugPort), Duration.ofSeconds(10L), terse);
288284
}
289285

290286
private static void checkFreeAdminPorts(List<HostAndPort> endpoints) throws GFLauncherException {

0 commit comments

Comments
 (0)