From 2af0312c958e693b1377f4c014ae8f84cabf6b83 Mon Sep 17 00:00:00 2001 From: Kevin Walls Date: Thu, 28 Mar 2024 11:34:44 +0000 Subject: [PATCH] 8328619: sun/management/jmxremote/bootstrap/SSLConfigFilePermissionTest.java failed with BindException: Address already in use Reviewed-by: lmesnik, dfuchs --- .../bootstrap/AbstractFilePermissionTest.java | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/test/jdk/sun/management/jmxremote/bootstrap/AbstractFilePermissionTest.java b/test/jdk/sun/management/jmxremote/bootstrap/AbstractFilePermissionTest.java index 727ca33a6bd..ddbca2c444d 100644 --- a/test/jdk/sun/management/jmxremote/bootstrap/AbstractFilePermissionTest.java +++ b/test/jdk/sun/management/jmxremote/bootstrap/AbstractFilePermissionTest.java @@ -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 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; }