MacOS file system changes between 7u10 and 7u40?

Philippe Marschall philippe.marschall at gmail.com
Fri Sep 20 10:32:30 UTC 2013


Hi

Have there been any changes to the way the default file system handles
Unicode normalization between 7u10 and 7u40? I'm suddenly seeing code
behave differently and I don't remember reading anything in the
changelogs. I'm seeing two differences:

First Path#toRealPath() return values seem to be NFC instead if NFD.
This is a bit confusing because AFAIK MacOS stores in NFD. This code
works in 7u10 but fails in 7u40

    FileSystem fileSystem = FileSystems.getDefault();
    String aUmlaut = "\u00C4";
    Path aPath = fileSystem.getPath(aUmlaut);
    String normalized = Normalizer.normalize(aUmlaut, Form.NFD);
    Path nPath = fileSystem.getPath(normalized);

    Path createdFile = null;
    try {
      createdFile = Files.createFile(aPath);
      assertEquals(1, createdFile.getFileName().toString().length());
      assertEquals(1,
createdFile.toAbsolutePath().getFileName().toString().length());
      assertEquals(2,
createdFile.toRealPath().getFileName().toString().length()); //
failure is here
   } finally {
      if (createdFile != null) {
        Files.delete(createdFile);
      }
    }

Second Path#equals now seems to normalize paths. This code works in
7u10 but fails in 7u40

    FileSystem fileSystem = FileSystems.getDefault();
    String aUmlaut = "\u00C4";
    String normalized = Normalizer.normalize(aUmlaut, Form.NFD);
    assertEquals(1, aUmlaut.length());
    assertEquals(2, normalized.length());
    Path aPath = fileSystem.getPath("/" + aUmlaut);
    Path nPath = fileSystem.getPath("/" + normalized);
    assertEquals(1, aPath.getName(0).toString().length());
    assertThat(aPath, not(equalTo(nPath)));

Cheers
Philippe


More information about the nio-dev mailing list