Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8204300

Files.move throws DirectoryNotEmptyException when moving directory across file system

    XMLWordPrintable

Details

    • CSR
    • Resolution: Approved
    • P4
    • 11
    • core-libs
    • None
    • behavioral
    • minimal
    • Hide
      There should be in effect no behavioral change. A DirectoryNotEmptyException is thrown for this case both with and without the source code changes. With the changes it is simply thrown earlier in the code path thereby saving some execution time. The modified test included in the patch behaves the same both with and without the code changes applied.
      Show
      There should be in effect no behavioral change. A DirectoryNotEmptyException is thrown for this case both with and without the source code changes. With the changes it is simply thrown earlier in the code path thereby saving some execution time. The modified test included in the patch behaves the same both with and without the code changes applied.
    • Java API
    • SE

    Description

      Summary

      Amend the verbiage describing when java.nio.file.Files.move() will throw the optional specific exception DirectoryNotEmptyException.

      Problem

      java.nio.file.Files.move() throws a DirectoryNotEmptyException when the source directory contains entries which would be required to be moved if the move is to another file system (device) but this situation is not explicitly described in the javadoc.

      Solution

      Include in the javadoc for java.nio.file.Files.move() that it will throw the optional specific exception DirectoryNotEmptyException in the case where the source directory is non-empty and the target is on another file system.

      Specification

      --- a/src/java.base/share/classes/java/nio/file/Files.java
      +++ b/src/java.base/share/classes/java/nio/file/Files.java
      @@ -1391,8 +1391,9 @@
            *          specific exception)</i>
            * @throws  DirectoryNotEmptyException
            *          the {@code REPLACE_EXISTING} option is specified but the file
      -     *          cannot be replaced because it is a non-empty directory
      -     *          <i>(optional specific exception)</i>
      +     *          cannot be replaced because it is a non-empty directory, or the
      +     *          source is a non-empty directory containing entries that would
      +     *          be required to be moved <i>(optional specific exceptions)</i>
            * @throws  AtomicMoveNotSupportedException
            *          if the options array contains the {@code ATOMIC_MOVE} option but
            *          the file cannot be moved as an atomic file system operation.

      Attachments

        Issue Links

          Activity

            People

              bpb Brian Burkhalter
              webbuggrp Webbug Group
              Alan Bateman
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: