Use a random time for plugin center updates

Pushed-by: Rene Pfeuffer<rene.pfeuffer@cloudogu.com>
Co-authored-by: René Pfeuffer<rene.pfeuffer@cloudogu.com>
This commit is contained in:
Rene Pfeuffer
2023-11-06 10:34:05 +01:00
parent b0d319f99b
commit f333a0bf18
2 changed files with 5 additions and 1 deletions

View File

@@ -0,0 +1,2 @@
- type: fixed
description: Use a random time for plugin center updates

View File

@@ -28,6 +28,7 @@ import sonia.scm.EagerSingleton;
import sonia.scm.schedule.Scheduler;
import javax.inject.Inject;
import java.util.Random;
/**
* Refresh plugin center cache and refresh the token of plugin center authentication.
@@ -40,7 +41,8 @@ public class PluginCenterRefresh {
@Inject
@SuppressWarnings("java:S1118") // could not hide constructor
public PluginCenterRefresh(Scheduler scheduler) {
scheduler.schedule("42 42 0/6 * * ?", RefreshTask.class);
Random random = new Random();
scheduler.schedule(String.format("%02d %02d 0/6 * * ?", random.nextInt(60), random.nextInt(60)), RefreshTask.class);
}
public static class RefreshTask implements Runnable {