Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-47324

FilePath API in Jenkins should propagate errors

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Almost all methods in https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/FilePath.java use obsolete pre-Java7 API, which does not propagate errors.

      • The code should be updated to java.nio.Files: https://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html
      • Methods should propagate errors via IOExceptions where possible (and log errors to java.util.logging.Logger otherwise)
      • Runtime exceptions from the new API should be caught if the methods throw them (e.g. InvalidPathException)

        Attachments

          Issue Links

            Activity

            Hide
            krishbhasin Krishan Bhasin added a comment -

            Devin Nusbaum Yeah sorry it's been a busy few weeks (holiday then knocked out with flu). I will get to this before the end of the year, I'm still recovering from the illness.

            Show
            krishbhasin Krishan Bhasin added a comment - Devin Nusbaum Yeah sorry it's been a busy few weeks (holiday then knocked out with flu). I will get to this before the end of the year, I'm still recovering from the illness.
            Hide
            dnusbaum Devin Nusbaum added a comment -

            Krishan Bhasin Ok that sounds good. I hope you're feeling better soon.

            Show
            dnusbaum Devin Nusbaum added a comment - Krishan Bhasin Ok that sounds good. I hope you're feeling better soon.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Krishan Bhasin
            Path:
            core/src/main/java/hudson/FilePath.java
            core/src/main/java/hudson/util/IOUtils.java
            http://jenkins-ci.org/commit/jenkins/09bcc5d6538b3cfffbf71228ebd1679e3e20d8b2
            Log:
            JENKINS-47324 - Reduce usage of File.mkdirs() in FilePath and IOUtils (#3173)

            • Move an instance of renameTo() to Files.move()
            • Replace an instance of File.toURI() with an instance of Path.toUri()
            • Replace mkdirs() with Files.createDirectories()
              Replace mkdir() with Files.createTempDirectory()
            • Undo addition of createTempDirectory() as per review comments
            • Return to use of FilePath#mkdirs(File) and instead modify it to use the new API.
            • Undo addition of toPath() in a URI conversion as it brings no benefits.
            • Replace new uses of toPath() with Util.fileToPath() to pre-handle runtime exceptions
            • Remove * import.
              move mkdirs() to using FilePath method instead of File method.
            • Make IOUtils.mkdirs(File) use Java7 API calls
            • Add back accidentally removed imports.
            • Fixed use of wildcard import
            • Use utility method fileToPath() to handle potential exception thrown
            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Krishan Bhasin Path: core/src/main/java/hudson/FilePath.java core/src/main/java/hudson/util/IOUtils.java http://jenkins-ci.org/commit/jenkins/09bcc5d6538b3cfffbf71228ebd1679e3e20d8b2 Log: JENKINS-47324 - Reduce usage of File.mkdirs() in FilePath and IOUtils (#3173) Move an instance of renameTo() to Files.move() Replace an instance of File.toURI() with an instance of Path.toUri() Replace mkdirs() with Files.createDirectories() Replace mkdir() with Files.createTempDirectory() Undo addition of createTempDirectory() as per review comments Return to use of FilePath#mkdirs(File) and instead modify it to use the new API. Undo addition of toPath() in a URI conversion as it brings no benefits. Replace new uses of toPath() with Util.fileToPath() to pre-handle runtime exceptions Remove * import. move mkdirs() to using FilePath method instead of File method. Make IOUtils.mkdirs(File) use Java7 API calls Add back accidentally removed imports. Fixed use of wildcard import Use utility method fileToPath() to handle potential exception thrown
            Hide
            danielbeck Daniel Beck added a comment -

            Oleg Nenashev Is this issue fixed towards 2.96 or still WIP?

            Show
            danielbeck Daniel Beck added a comment - Oleg Nenashev Is this issue fixed towards 2.96 or still WIP?
            Hide
            oleg_nenashev Oleg Nenashev added a comment -

            Daniel Beck IIUC there are still some changes to be done in this ticket

            Show
            oleg_nenashev Oleg Nenashev added a comment - Daniel Beck IIUC there are still some changes to be done in this ticket

              People

              • Assignee:
                krishbhasin Krishan Bhasin
                Reporter:
                oleg_nenashev Oleg Nenashev
              • Votes:
                1 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated: