RFR: 8273922: (fs) UserDefinedFileAttributeView doesn't handle file names that are just under the MAX_PATH limit (win) [v5]

Mike Hearn duke at openjdk.java.net
Thu Nov 11 18:04:41 UTC 2021


On Wed, 3 Nov 2021 18:46:48 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   8273922: Change getNameCount() != 1 tp getParent() != null
>
> That would be the third commit, labelled 02 (zero-relative).

@bplb That commit seems to have the same problem. Here's a test diff that shows the issue:


diff --git a/test/jdk/java/nio/file/attribute/UserDefinedFileAttributeView/Basic.java b/test/jdk/java/nio/file/attribute/UserDefinedFileAttributeView/Basic.java
index bc47b8719f2..769de937e7c 100644
--- a/test/jdk/java/nio/file/attribute/UserDefinedFileAttributeView/Basic.java
+++ b/test/jdk/java/nio/file/attribute/UserDefinedFileAttributeView/Basic.java
@@ -235,9 +235,16 @@ public class Basic {
                 view.read(ATTR_NAME, buf);
             }});

-        // Long attribute name
+        // Windows has special rules for "long" paths.
         if (Platform.isWindows()) {
             Path tmp = Files.createTempDirectory(dir, "ea-length-bug");
+
+            // Create a file with a path name longer than MAX_PATH. This just verifies no exception is thrown.
+            Path longFilePath = tmp.resolve("y".repeat(300));
+            Files.write(longFilePath, "y".getBytes(StandardCharsets.UTF_8));
+            setEA(longFilePath, "user:ea");
+
+            // Long attribute name.
             int len = tmp.toString().length();

             // We need to run up to MAX_PATH for directories,


There's no test that checks EAs work on ordinary long file names. The above shows the failure, because `WindowsPath.createFromNormalizedPath` is called and it doesn't seem to understand the `\?` prefix.

-------------

PR: https://git.openjdk.java.net/jdk/pull/5594


More information about the nio-dev mailing list