Skip to content

Commit

Permalink
8328619: sun/management/jmxremote/bootstrap/SSLConfigFilePermissionTe…
Browse files Browse the repository at this point in the history
…st.java failed with BindException: Address already in use

Backport-of: 2af0312
  • Loading branch information
GoeLin committed Nov 21, 2024
1 parent 4ea9694 commit dcac5eb
Showing 1 changed file with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -41,8 +41,8 @@
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
*/
Expand Down Expand Up @@ -140,21 +140,25 @@ private void test1() throws Exception {
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);
perms.add(PosixFilePermission.OTHERS_READ);
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;
}
}
Expand All @@ -172,7 +176,6 @@ private int doTest() throws Exception {
command.add(TEST_CLASSES);
command.add(className);


ProcessBuilder processBuilder = ProcessTools.createTestJavaProcessBuilder(command);

System.out.println("test cmdline: " + Arrays.toString(processBuilder.command().toArray()).replace(",", ""));
Expand All @@ -181,13 +184,15 @@ private int doTest() throws Exception {
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;
}

Expand Down

0 comments on commit dcac5eb

Please sign in to comment.