RFR: 8355954: File.delete removes read-only files (win) [v4]
Brian Burkhalter
bpb at openjdk.org
Fri May 16 17:25:54 UTC 2025
On Fri, 16 May 2025 06:28:14 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> test/jdk/java/io/File/DeleteReadOnly.java line 47:
>>
>>> 45:
>>> 46: private static final File DIR = new File(".", "dir");
>>> 47: private static final File FILE = new File(DIR, "file");
>>
>> If one of the tests fails then it will impact the test(s) that execute later. It might be better to just isolate them. deleteReadOnlyDirectory creates a directory that is used solely for that test, and deleteReadOnlyRegularFile creates a file that is used solely for that test.
>
> Agreed. That actually happened when negative testing against code without the fix.
Made directory and file creation local to each test in [fa2273e](https://github.com/openjdk/jdk/pull/24977/commits/fa2273eded040a22c1e32ba8870571d3a7daf427).
>> test/jdk/java/io/File/DeleteReadOnly.java line 62:
>>
>>> 60:
>>> 61: boolean deleted = FILE.delete();
>>> 62: boolean shouldBeDeleted = !Platform.isWindows() || DELETE_READ_ONLY;
>>
>> The behavior and system property is Windows specific and might make things simpler to make it a Windows only test.
>
> I guess collapsing the tests made them more ambiguous. Will fix.
Split the test method in half for Unix and Windows in [fa2273e](https://github.com/openjdk/jdk/pull/24977/commits/fa2273eded040a22c1e32ba8870571d3a7daf427).
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24977#discussion_r2093430454
PR Review Comment: https://git.openjdk.org/jdk/pull/24977#discussion_r2093429650
More information about the core-libs-dev
mailing list