8328619: sun/management/jmxremote/bootstrap/SSLConfigFilePermissionTest.java failed with BindException: Address already in use

Reviewed-by: lmesnik, dfuchs
This commit is contained in:
Kevin Walls 2024-03-28 11:34:44 +00:00
parent 7c7b961e73
commit 2af0312c95

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -41,8 +41,8 @@ import java.util.List;
import java.util.Set;
/**
* Change file permission for out-of-the-box management an do test used by
* PasswordFilePermissionTest and SSLConfigFilePermissionTest tests
* Change file permission for out-of-the-box management, and test.
* Used by PasswordFilePermissionTest and SSLConfigFilePermissionTest tests.
*
* @author Taras Ledkov
*/
@ -140,13 +140,15 @@ public abstract class AbstractFilePermissionTest {
perms_0700.add(PosixFilePermission.OWNER_EXECUTE);
Files.setPosixFilePermissions(file2PermissionTest, perms_0700);
if (doTest() != 0) {
int e = doTest();
if (e != 0) {
System.out.println("FAILURE: expected exit code 0, got: " + e);
++failures;
}
}
/**
* Test 1 - SSL config file is secure - VM should start
* Test 2 - SSL config file is NOT secure - VM should not start
*/
private void test2() throws Exception {
final Set<PosixFilePermission> perms = Files.getPosixFilePermissions(file2PermissionTest);
@ -154,7 +156,9 @@ public abstract class AbstractFilePermissionTest {
perms.add(PosixFilePermission.OTHERS_EXECUTE);
Files.setPosixFilePermissions(file2PermissionTest, perms);
if (doTest() == 0) {
int e = doTest();
if (e == 0) {
System.out.println("FAILURE: expected exit code non-zero, got: " + e);
++failures;
}
}
@ -172,7 +176,6 @@ public abstract class AbstractFilePermissionTest {
command.add(TEST_CLASSES);
command.add(className);
ProcessBuilder processBuilder = ProcessTools.createTestJavaProcessBuilder(command);
System.out.println("test cmdline: " + Arrays.toString(processBuilder.command().toArray()).replace(",", ""));
@ -181,13 +184,15 @@ public abstract class AbstractFilePermissionTest {
System.out.println("test output:");
System.out.println(output.getOutput());
if ((output.getExitValue() == 0) ||
!output.getOutput().contains("Exception thrown by the agent : " +
"java.rmi.server.ExportException: Port already in use")) {
return output.getExitValue();
if (output.getOutput().contains("Exception thrown by the agent: java.rmi.server.ExportException: Port already in use")) {
if (i < MAX_GET_FREE_PORT_TRIES - 1) {
System.out.println("Retrying...");
continue;
}
}
// Fail on too many port failures, and all other startup failures.
return output.getExitValue();
}
return -1;
}