From 67ab91263bf957b7f1b5405380b64b8c39e749bc Mon Sep 17 00:00:00 2001 From: Mark Waite Date: Fri, 13 Sep 2024 22:52:12 -0600 Subject: [PATCH] [JENKINS-73775] Replace deprecated call to JGit setLastModified(long) JGit 5 deprecated the DirCacheEntry.setLastModified(long) method and recommends DirCacheEntry.setLastModified(Instant). JGit 7.0.0 removes DirCacheEntry.setLastModified(long). This change will work with old versions of JGit and JGit 7.0.0 because the replacement method is available with older versions and the most recent release. Javadoc for JGit 6.9.0 is available at https://javadoc.io/doc/org.eclipse.jgit/org.eclipse.jgit/6.9.0.202403050737-r/org.eclipse.jgit/org/eclipse/jgit/dircache/DirCacheEntry.html Without this change, users that try to run the Git portion of Blue Ocean may see a method not found exception that will fail the operation. --- .../io/jenkins/blueocean/blueocean_git_pipeline/GitUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/blueocean-git-pipeline/src/main/java/io/jenkins/blueocean/blueocean_git_pipeline/GitUtils.java b/blueocean-git-pipeline/src/main/java/io/jenkins/blueocean/blueocean_git_pipeline/GitUtils.java index 5c6b99b11b..f040c2c5d9 100644 --- a/blueocean-git-pipeline/src/main/java/io/jenkins/blueocean/blueocean_git_pipeline/GitUtils.java +++ b/blueocean-git-pipeline/src/main/java/io/jenkins/blueocean/blueocean_git_pipeline/GitUtils.java @@ -71,6 +71,7 @@ import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.text.MessageFormat; +import java.time.Instant; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -405,7 +406,7 @@ private static DirCache createTemporaryIndex(final Repository repo, final Object final DirCache inCoreIndex = DirCache.newInCore(); final DirCacheBuilder dcBuilder = inCoreIndex.builder(); try (final ObjectInserter inserter = repo.newObjectInserter()) { - long lastModified = System.currentTimeMillis(); + Instant lastModified = Instant.now(); try { if (contents != null) {