Skip to content

Commit 3de6758

Browse files
committed
Suppress SpotBugs warning about non-final constant and rename parameter for clarity
1 parent 9291bfe commit 3de6758

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/main/java/org/jenkinsci/plugins/workflow/libs/LibraryCachingCleanup.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.jenkinsci.plugins.workflow.libs;
22

3+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
34
import hudson.Extension;
45
import hudson.FilePath;
56
import hudson.model.AsyncPeriodicWork;
@@ -11,7 +12,8 @@
1112
import jenkins.util.SystemProperties;
1213

1314
@Extension public class LibraryCachingCleanup extends AsyncPeriodicWork {
14-
public static /* non-final for script console */ int EXPIRE_AFTER_READ_DAYS =
15+
@SuppressFBWarnings(value = "MS_SHOULD_BE_FINAL", justification = "non-final for script console access")
16+
public static int EXPIRE_AFTER_READ_DAYS =
1517
SystemProperties.getInteger(LibraryCachingCleanup.class.getName() + ".EXPIRE_AFTER_READ_DAYS", 7);
1618

1719
public LibraryCachingCleanup() {
@@ -40,10 +42,10 @@ public LibraryCachingCleanup() {
4042
* @return true if specified directory is a cache directory, regardless of whether it was outdated. Used to detect
4143
* whether the cache was created before or after the fix for SECURITY-2586.
4244
*/
43-
private boolean removeIfOldCacheDirectory(FilePath library, long maxDurationMillis) throws IOException, InterruptedException {
45+
private boolean removeIfOldCacheDirectory(FilePath library, long maxDurationSinceLastReadMillis) throws IOException, InterruptedException {
4446
final FilePath lastReadFile = new FilePath(library, LibraryCachingConfiguration.LAST_READ_FILE);
4547
if (lastReadFile.exists()) {
46-
if ((System.currentTimeMillis() - lastReadFile.lastModified()) > maxDurationMillis) {
48+
if ((System.currentTimeMillis() - lastReadFile.lastModified()) > maxDurationSinceLastReadMillis) {
4749
library.deleteRecursive();
4850
library.withSuffix("-name.txt").delete(); // Harmless if this is a pre-SECURITY-2586 cache directory.
4951
}

0 commit comments

Comments
 (0)