Skip to content

Commit

Permalink
Merge pull request #492 from amaximus/bugfix/JENKINS-71645
Browse files Browse the repository at this point in the history
[JENKINS-71645] Fix Project list fetch interval parameter
  • Loading branch information
rsandell authored Jul 17, 2023
2 parents 475e265 + fef9094 commit 7de6104
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public int getTimerUpdatePeriod() {
*/
public void setTimerUpdatePeriod(int timerUpdatePeriod) {
this.timerUpdatePeriod = timerUpdatePeriod;
scheduleProjectListUpdate(0);
scheduleProjectListUpdate(0, timerUpdatePeriod);
}

/**
Expand Down Expand Up @@ -180,7 +180,8 @@ public void initProjectListUpdater() {
return;
}
timer = new Timer(serverName);
scheduleProjectListUpdate(getConfig().getProjectListFetchDelay());
scheduleProjectListUpdate(getConfig().getProjectListFetchDelay(),
getConfig().getProjectListRefreshInterval());
} else {
logger.error("Can't create two timers for the same Gerrit instance: " + serverName);
}
Expand All @@ -207,8 +208,9 @@ public void cancelProjectListUpdater() {
* This method creates a timer that schedule the update of the gerrit project list.
*
* @param initDelay the initial delay, in seconds.
* @param updatePeriod the update period, in seconds.
*/
public void scheduleProjectListUpdate(int initDelay) {
public void scheduleProjectListUpdate(int initDelay, int updatePeriod) {
logger.info("Start timer to update project list");
if (timer != null) {
timer.cancel();
Expand All @@ -218,7 +220,7 @@ public void scheduleProjectListUpdate(int initDelay) {
public void run() {
tryLoadProjectList();
}
}, TimeUnit.SECONDS.toMillis(initDelay), TimeUnit.MINUTES.toMillis(timerUpdatePeriod));
}, TimeUnit.SECONDS.toMillis(initDelay), TimeUnit.MINUTES.toMillis(updatePeriod));
} else {
logger.error("Unable to schedule project list update task because timer is null");
}
Expand Down

0 comments on commit 7de6104

Please sign in to comment.