Skip to content

Commit 322fc81

Browse files
committed
8328619: sun/management/jmxremote/bootstrap/SSLConfigFilePermissionTest.java failed with BindException: Address already in use
Backport-of: 2af0312c958e693b1377f4c014ae8f84cabf6b83
1 parent 3aa59b3 commit 322fc81

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

test/jdk/sun/management/jmxremote/bootstrap/AbstractFilePermissionTest.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -41,8 +41,8 @@
4141
import java.util.Set;
4242

4343
/**
44-
* Change file permission for out-of-the-box management an do test used by
45-
* PasswordFilePermissionTest and SSLConfigFilePermissionTest tests
44+
* Change file permission for out-of-the-box management, and test.
45+
* Used by PasswordFilePermissionTest and SSLConfigFilePermissionTest tests.
4646
*
4747
* @author Taras Ledkov
4848
*/
@@ -140,21 +140,25 @@ private void test1() throws Exception {
140140
perms_0700.add(PosixFilePermission.OWNER_EXECUTE);
141141
Files.setPosixFilePermissions(file2PermissionTest, perms_0700);
142142

143-
if (doTest() != 0) {
143+
int e = doTest();
144+
if (e != 0) {
145+
System.out.println("FAILURE: expected exit code 0, got: " + e);
144146
++failures;
145147
}
146148
}
147149

148150
/**
149-
* Test 1 - SSL config file is secure - VM should start
151+
* Test 2 - SSL config file is NOT secure - VM should not start
150152
*/
151153
private void test2() throws Exception {
152154
final Set<PosixFilePermission> perms = Files.getPosixFilePermissions(file2PermissionTest);
153155
perms.add(PosixFilePermission.OTHERS_READ);
154156
perms.add(PosixFilePermission.OTHERS_EXECUTE);
155157
Files.setPosixFilePermissions(file2PermissionTest, perms);
156158

157-
if (doTest() == 0) {
159+
int e = doTest();
160+
if (e == 0) {
161+
System.out.println("FAILURE: expected exit code non-zero, got: " + e);
158162
++failures;
159163
}
160164
}
@@ -172,7 +176,6 @@ private int doTest() throws Exception {
172176
command.add(TEST_CLASSES);
173177
command.add(className);
174178

175-
176179
ProcessBuilder processBuilder = ProcessTools.createTestJavaProcessBuilder(command);
177180

178181
System.out.println("test cmdline: " + Arrays.toString(processBuilder.command().toArray()).replace(",", ""));
@@ -181,13 +184,15 @@ private int doTest() throws Exception {
181184
System.out.println("test output:");
182185
System.out.println(output.getOutput());
183186

184-
if ((output.getExitValue() == 0) ||
185-
!output.getOutput().contains("Exception thrown by the agent : " +
186-
"java.rmi.server.ExportException: Port already in use")) {
187-
return output.getExitValue();
187+
if (output.getOutput().contains("Exception thrown by the agent: java.rmi.server.ExportException: Port already in use")) {
188+
if (i < MAX_GET_FREE_PORT_TRIES - 1) {
189+
System.out.println("Retrying...");
190+
continue;
191+
}
188192
}
193+
// Fail on too many port failures, and all other startup failures.
194+
return output.getExitValue();
189195
}
190-
191196
return -1;
192197
}
193198

0 commit comments

Comments
 (0)