FileUtils.copyDirectory() used Files.copy() for all entries including 
directories. When the destination is an existing directory (like PWD), 
Files.copy with REPLACE_EXISTING replaces the directory inode, corrupting it. 
Fixed by using Files.createDirectories() for directory entries and Files.copy() 
only for files. Added test verifying copyDirectory to PWD works correctly.

---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK 
Interim AI Policy](https://openjdk.org/legal/ai).

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

Commit messages:
 - 8355320: FileUtils.copyDirectory() corrupts existing directory

Changes: https://git.openjdk.org/jdk/pull/31444/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=31444&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8355320
  Stats: 37 lines in 2 files changed: 32 ins; 0 del; 5 mod
  Patch: https://git.openjdk.org/jdk/pull/31444.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/31444/head:pull/31444

PR: https://git.openjdk.org/jdk/pull/31444

Reply via email to