Skip to content

Commit bddc072

Browse files
committed
Using Instant time module for cache expiry.
1 parent 5056c1a commit bddc072

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main/java/com/browserstack/automate/ci/jenkins/qualityDashboard/QualityDashboardPipelineTracker.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.nio.file.Path;
2323
import java.nio.file.Paths;
2424
import java.sql.Timestamp;
25+
import java.time.Instant;
2526
import java.util.logging.Logger;
2627

2728
@Extension
@@ -349,18 +350,17 @@ private String getJobNameFromRun(Run<?, ?> run, BrowserStackCredentials browserS
349350
}
350351
private static class QDEnabledCache {
351352
private static volatile Boolean qdEnabled = null;
352-
private static volatile long expiryTime = 0L;
353-
353+
private static volatile Instant expiryTime = Instant.EPOCH;
354+
354355
public static Boolean getCachedValue() {
355-
if (qdEnabled != null && System.currentTimeMillis() < expiryTime) {
356+
if (qdEnabled != null && Instant.now().isBefore(expiryTime)) {
356357
return qdEnabled;
357358
}
358359
return null; // Cache expired or not set
359360
}
360-
361361
public static void setCachedValue(boolean value) {
362362
qdEnabled = value;
363-
expiryTime = System.currentTimeMillis() + Constants.QualityDashboardAPI.CACHE_DURATION_MS;
363+
expiryTime = Instant.now().plusMillis(Constants.QualityDashboardAPI.CACHE_DURATION_MS);
364364
}
365365
}
366366
}

0 commit comments

Comments
 (0)