Uploaded image for project: 'Gradle'
  1. Gradle
  2. GRADLE-3369

Inconsistent behavior of FileTreeElement getSize/getLastModified methods

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.11-rc-1

      Description

      Depending on which version of the JDK you run Gradle with, any method that receives a FileTreeElement (mainly FileTree/FileCollection visit and eachFile FileCopyDetails) could see different behavior when calling getSize and getLastModified methods.

      For JDK6, Gradle will usually return the size and last modified time of the underlying file at the time it is asked for. Any subsequent calls will return the same cached value.

      For JDK7+, Gradle will usually return the size and last modified time of the underlying file when the file's parent has been visited. Any subsequent calls will return the same cached value.

      In some cases, changes to the file will be reflected every time when calling getSize or getLastModified.

      This inconsistency could cause problems if a task modifies files while visiting them and expects to see those changes reflected in the FileVisitDetails/FileTreeElement/FileCopyDetails getSize or getLastModified properties. This is uncommon behavior in most builds.

      We plan to make this behavior consistent by always caching these values when the parent is visited. If you never want to see the cached values, we recommend using getFile().size() or getFile().lastModified() instead. This goes directly to the underlying file.

        Attachments

          Activity

            People

            Assignee:
            lhotari Lari Hotari
            Reporter:
            big-guy Sterling Greene
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: