Skip to content
Permalink
Browse files
Fix of too-short history: negative values in build start time cache fix
  • Loading branch information
dspavlov committed Jun 26, 2019
1 parent be469c9 commit 9801cc649353390cf0e76b8bdeb808100d443bac
Showing 1 changed file with 12 additions and 4 deletions.
@@ -141,11 +141,18 @@ public boolean buildWasProcessed(int srvId, int buildId) {
*/
@AutoProfiling
@Nullable public Long getBuildStartTime(int srvId, int buildId) {
return buildStartTime.get(buildIdToCacheKey(srvId, buildId));
Long ts = buildStartTime.get(buildIdToCacheKey(srvId, buildId));
if (ts == null || ts <= 0)
return null;

return ts;
}

@AutoProfiling
public boolean setBuildProcessed(int srvId, int buildId, long ts) {
if (ts <= 0)
return false;

return buildStartTime.putIfAbsent(buildIdToCacheKey(srvId, buildId), ts);
}

@@ -253,8 +260,9 @@ public Map<Integer, Long> getBuildsStartTime(int srvId, Set<Integer> ids) {

Map<Integer, Long> res = new HashMap<>();

buildStartTime.getAll(cacheKeys).forEach((k, r) -> {
res.put(BuildRefDao.cacheKeyToBuildId(k), r);
buildStartTime.getAll(cacheKeys).forEach((k, ts) -> {
if (ts != null && ts > 0)
res.put(BuildRefDao.cacheKeyToBuildId(k), ts);
});

return res;
@@ -264,7 +272,7 @@ public void setBuildsStartTime(int srvId, Map<Integer, Long> builds) {
Map<Long, Long> res = new HashMap<>();

builds.forEach((buildId, ts) -> {
if (ts != null)
if (ts != null && ts > 0)
res.put(buildIdToCacheKey(srvId, buildId), ts);
});

0 comments on commit 9801cc6

Please sign in to comment.