• Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • core

      Util.loadFile() first checks if the file exists via File.exists(). It then tries to open the file for reading. However, it is possible for the file to be deleted between the existence check and the file-open operation, in which case the method throws a FileNotFoundException rather than returning an empty string.

          [JENKINS-49971] hudson.Util.loadFile() has a race condition

          Daniel Trebbien added a comment - https://github.com/jenkinsci/jenkins/pull/3225

          Oleg Nenashev added a comment -

          The patch has been integrated towards 2.111

          Oleg Nenashev added a comment - The patch has been integrated towards 2.111

          Code changed in jenkins
          User: Daniel Trebbien
          Path:
          core/src/main/java/hudson/Util.java
          http://jenkins-ci.org/commit/jenkins/aa799e39ad904183d1da3105b8b3267c7348cd71
          Log:
          JENKINS-49971 Fix a race condition in Util.loadFile() (#3225)

          • Fix a race condition in Util.loadFile()

          If the file is deleted in between when its existence is checked and the
          file is opened for reading, then the method will fail to return an empty
          string.

          • Switch to using FileUtils.readFileToString()

          (cherry picked from commit aaae71af4bd2952efdc3462fde086faa6a604ee2)

          Compare: https://github.com/jenkinsci/jenkins/compare/115612bbf558...aa799e39ad90

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Daniel Trebbien Path: core/src/main/java/hudson/Util.java http://jenkins-ci.org/commit/jenkins/aa799e39ad904183d1da3105b8b3267c7348cd71 Log: JENKINS-49971 Fix a race condition in Util.loadFile() (#3225) Fix a race condition in Util.loadFile() If the file is deleted in between when its existence is checked and the file is opened for reading, then the method will fail to return an empty string. Switch to using FileUtils.readFileToString() (cherry picked from commit aaae71af4bd2952efdc3462fde086faa6a604ee2) Compare: https://github.com/jenkinsci/jenkins/compare/115612bbf558...aa799e39ad90

            Unassigned Unassigned
            dtrebbien Daniel Trebbien
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: