Skip to content

Commit de8ee97

Browse files
SendaoYannaotoj
authored andcommitted
8334333: MissingResourceCauseTestRun.java fails if run by root
Reviewed-by: naoto, jlu
1 parent 265a0f5 commit de8ee97

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

test/jdk/java/util/ResourceBundle/Control/MissingResourceCauseTestRun.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2007, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2007, 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
@@ -23,7 +23,7 @@
2323

2424
/*
2525
* @test
26-
* @bug 4354216 8213127
26+
* @bug 4354216 8213127 8334333
2727
* @summary Test for the cause support when throwing a
2828
* MissingResourceBundle. (This test exists under
2929
* ResourceBundle/Control because bad resource bundle data can be
@@ -32,6 +32,7 @@
3232
* @build jdk.test.lib.JDKToolLauncher
3333
* jdk.test.lib.Utils
3434
* jdk.test.lib.process.ProcessTools
35+
* jdk.test.lib.Platform
3536
* MissingResourceCauseTest
3637
* NonResourceBundle
3738
* PrivateConstructorRB
@@ -50,9 +51,14 @@
5051
import jdk.test.lib.JDKToolLauncher;
5152
import jdk.test.lib.Utils;
5253
import jdk.test.lib.process.ProcessTools;
54+
import jdk.test.lib.Platform;
55+
import jtreg.SkippedException;
5356

5457
public class MissingResourceCauseTestRun {
5558
public static void main(String[] args) throws Throwable {
59+
if (Platform.isRoot() && !Platform.isWindows()) {
60+
throw new SkippedException("Unable to create an unreadable properties file.");
61+
}
5662
Path path = Paths.get("UnreadableRB.properties");
5763
Files.deleteIfExists(path);
5864
try {
@@ -98,7 +104,7 @@ private static void runCmd() throws Throwable {
98104
}
99105

100106
private static void deleteFile(Path path) throws Throwable {
101-
if(path.toFile().exists()) {
107+
if (path.toFile().exists()) {
102108
ProcessTools.executeCommand("chmod", "666", path.toString())
103109
.outputTo(System.out)
104110
.errorTo(System.out)

0 commit comments

Comments
 (0)