People occasionally report class loading problems which go away when the Remoting cache is cleared. (Incoherent InvalidClassException; empty ZIP.) Root cause is TBD, but in the meantime FileSystemJarCache.retrieve is not sufficiently robust.

      • After calling JarLoaderImpl.writeJarTo, it does not verify that tmp actually has the expected checksum. What if the other side sent corrupt content, or a zero-length stream?
      • File.renameTo is not guaranteed to be atomic. If on Java 7, should use Files.move(tmp.toPath(), target.toPath(), StandardCopyOption.ATOMIC_MOVE) to be sure there is no race condition.

          [JENKINS-26759] FileSystemJarCache not defensive enough

          akshay_abd added a comment -

          We're still on JDK 6 right? So we can't use Files.move - correct? We can at least verify the checksums.

          akshay_abd added a comment - We're still on JDK 6 right? So we can't use Files.move - correct? We can at least verify the checksums.

          Jesse Glick added a comment -

          We are planning to switch to Java 7 in the near future, assuming there is no major pushback from users, but for the moment the baseline is indeed still Java 6. You can perhaps use Files.move reflectively. Anyway I sort of doubt that is the issue; a file with corrupt content seems more likely to me.

          By the way tfennelly tried hard to dig into a reported case of this but just could not reproduce or get a clear picture of what went wrong.

          Jesse Glick added a comment - We are planning to switch to Java 7 in the near future, assuming there is no major pushback from users, but for the moment the baseline is indeed still Java 6. You can perhaps use Files.move reflectively. Anyway I sort of doubt that is the issue; a file with corrupt content seems more likely to me. By the way tfennelly tried hard to dig into a reported case of this but just could not reproduce or get a clear picture of what went wrong.

          akshay_abd added a comment -

          k - if it is a case of a corrupt file we can at least verify the checksum as you mentioned.

          I've opened https://github.com/jenkinsci/remoting/pull/44 for review that does this.

          akshay_abd added a comment - k - if it is a case of a corrupt file we can at least verify the checksum as you mentioned. I've opened https://github.com/jenkinsci/remoting/pull/44 for review that does this.

          Code changed in jenkins
          User: Akshay Dayal
          Path:
          src/main/java/hudson/remoting/Checksum.java
          src/main/java/hudson/remoting/FileSystemJarCache.java
          src/main/java/hudson/remoting/JarLoaderImpl.java
          src/main/java/hudson/remoting/RemoteClassLoader.java
          src/test/java/hudson/remoting/ChecksumTest.java
          src/test/java/hudson/remoting/FileSystemJarCacheTest.java
          http://jenkins-ci.org/commit/remoting/07509891ab5c16b85e115b2174a59ffdfe55db60
          Log:
          JENKINS-26759 Make FileSystemJarCache more defensive. After a jar is fetched verify the checksum matches the expected value, if not throw an exception.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Akshay Dayal Path: src/main/java/hudson/remoting/Checksum.java src/main/java/hudson/remoting/FileSystemJarCache.java src/main/java/hudson/remoting/JarLoaderImpl.java src/main/java/hudson/remoting/RemoteClassLoader.java src/test/java/hudson/remoting/ChecksumTest.java src/test/java/hudson/remoting/FileSystemJarCacheTest.java http://jenkins-ci.org/commit/remoting/07509891ab5c16b85e115b2174a59ffdfe55db60 Log: JENKINS-26759 Make FileSystemJarCache more defensive. After a jar is fetched verify the checksum matches the expected value, if not throw an exception.

          Code changed in jenkins
          User: Kohsuke Kawaguchi
          Path:
          src/main/java/hudson/remoting/Checksum.java
          src/main/java/hudson/remoting/FileSystemJarCache.java
          src/main/java/hudson/remoting/JarLoaderImpl.java
          src/test/java/hudson/remoting/ChecksumTest.java
          src/test/java/hudson/remoting/FileSystemJarCacheTest.java
          http://jenkins-ci.org/commit/remoting/94ce96d639b7b32f64a29afc632fbded4ba3a4b8
          Log:
          Merge pull request #44 from akshayabd/JENKINS-26759

          JENKINS-26759 Make FileSystemJarCache more defensive

          Compare: https://github.com/jenkinsci/remoting/compare/846b3e0527aa...94ce96d639b7

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Kohsuke Kawaguchi Path: src/main/java/hudson/remoting/Checksum.java src/main/java/hudson/remoting/FileSystemJarCache.java src/main/java/hudson/remoting/JarLoaderImpl.java src/test/java/hudson/remoting/ChecksumTest.java src/test/java/hudson/remoting/FileSystemJarCacheTest.java http://jenkins-ci.org/commit/remoting/94ce96d639b7b32f64a29afc632fbded4ba3a4b8 Log: Merge pull request #44 from akshayabd/ JENKINS-26759 JENKINS-26759 Make FileSystemJarCache more defensive Compare: https://github.com/jenkinsci/remoting/compare/846b3e0527aa...94ce96d639b7

          Code changed in jenkins
          User: Akshay Dayal
          Path:
          src/main/java/hudson/remoting/FileSystemJarCache.java
          src/test/java/hudson/remoting/FileSystemJarCacheTest.java
          http://jenkins-ci.org/commit/remoting/217ff5751a896946743b836f5031cfc468254e98
          Log:
          JENKINS-26759 Add more tests for FileSystemJarCache

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Akshay Dayal Path: src/main/java/hudson/remoting/FileSystemJarCache.java src/test/java/hudson/remoting/FileSystemJarCacheTest.java http://jenkins-ci.org/commit/remoting/217ff5751a896946743b836f5031cfc468254e98 Log: JENKINS-26759 Add more tests for FileSystemJarCache

          Code changed in jenkins
          User: Oleg Nenashev
          Path:
          src/main/java/hudson/remoting/FileSystemJarCache.java
          src/test/java/hudson/remoting/FileSystemJarCacheTest.java
          http://jenkins-ci.org/commit/remoting/40c93cf9ab1f5f44c1e5b84464ed4d1900d94367
          Log:
          Merge pull request #46 from akshayabd/JENKINS-26759_2

          JENKINS-26759 Add more tests for FileSystemJarCache

          Compare: https://github.com/jenkinsci/remoting/compare/83f65546c223...40c93cf9ab1f

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oleg Nenashev Path: src/main/java/hudson/remoting/FileSystemJarCache.java src/test/java/hudson/remoting/FileSystemJarCacheTest.java http://jenkins-ci.org/commit/remoting/40c93cf9ab1f5f44c1e5b84464ed4d1900d94367 Log: Merge pull request #46 from akshayabd/ JENKINS-26759 _2 JENKINS-26759 Add more tests for FileSystemJarCache Compare: https://github.com/jenkinsci/remoting/compare/83f65546c223...40c93cf9ab1f

          akshay_abd added a comment -

          jglick feel free to verify if needed.

          akshay_abd added a comment - jglick feel free to verify if needed.

            akshay_abd akshay_abd
            jglick Jesse Glick
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: