8334333: MissingResourceCauseTestRun.java fails if run by root

Reviewed-by: naoto, jlu
This commit is contained in:
SendaoYan 2024-06-20 18:04:58 +00:00 committed by Naoto Sato
parent 265a0f5547
commit de8ee97718

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 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
@ -23,7 +23,7 @@
/*
* @test
* @bug 4354216 8213127
* @bug 4354216 8213127 8334333
* @summary Test for the cause support when throwing a
* MissingResourceBundle. (This test exists under
* ResourceBundle/Control because bad resource bundle data can be
@ -32,6 +32,7 @@
* @build jdk.test.lib.JDKToolLauncher
* jdk.test.lib.Utils
* jdk.test.lib.process.ProcessTools
* jdk.test.lib.Platform
* MissingResourceCauseTest
* NonResourceBundle
* PrivateConstructorRB
@ -50,9 +51,14 @@ import java.nio.file.Paths;
import jdk.test.lib.JDKToolLauncher;
import jdk.test.lib.Utils;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.Platform;
import jtreg.SkippedException;
public class MissingResourceCauseTestRun {
public static void main(String[] args) throws Throwable {
if (Platform.isRoot() && !Platform.isWindows()) {
throw new SkippedException("Unable to create an unreadable properties file.");
}
Path path = Paths.get("UnreadableRB.properties");
Files.deleteIfExists(path);
try {