@@ -161,36 +161,35 @@ private void scheduleNextCheck()
161
161
return ;
162
162
}
163
163
164
- this .nextScheduledCheck = Instant .now ().plus ( 1 , ChronoUnit .MINUTES );
165
- executorService .schedule ( new PeriodicCheck (), 1 , TimeUnit .MINUTES );
166
-
167
- /*
168
164
final VersionCheckInfoCache localCache = cacheHolder .getVersionCheckInfoCache ();
169
165
166
+ this .nextScheduledCheck = calculateNextScheduledCheck ( localCache , settings );
167
+
168
+ final TimeDuration delayUntilNextExecution = TimeDuration .fromCurrent ( this .nextScheduledCheck );
169
+
170
+ executorService .schedule ( new PeriodicCheck (), delayUntilNextExecution .asMillis (), TimeUnit .MILLISECONDS );
171
+
172
+ LOGGER .trace ( SessionLabel .VERSIONCHECK_SESSION_LABEL , () -> "scheduled next check execution at " + JavaHelper .toIsoDate ( nextScheduledCheck )
173
+ + " in " + delayUntilNextExecution .asCompactString () );
174
+ }
175
+
176
+ private static Instant calculateNextScheduledCheck ( final VersionCheckInfoCache localCache , final VersionCheckSettings settings )
177
+ {
170
178
final TimeDuration idealDurationUntilNextCheck = localCache .getLastError () != null && localCache .getCurrentVersion () == null
171
179
? settings .getCheckIntervalError ()
172
180
: settings .getCheckInterval ();
173
181
174
182
if ( localCache .getLastCheckTimestamp () == null )
175
183
{
176
- this.nextScheduledCheck = Instant.now().plus( 10, ChronoUnit.SECONDS );
184
+ return Instant .now ().plus ( 10 , ChronoUnit .SECONDS );
177
185
}
178
186
else
179
187
{
180
188
final Instant nextIdealTimestamp = localCache .getLastCheckTimestamp ().plus ( idealDurationUntilNextCheck .asDuration () );
181
- this.nextScheduledCheck = nextIdealTimestamp.isBefore( Instant.now() )
189
+ return nextIdealTimestamp .isBefore ( Instant .now () )
182
190
? Instant .now ().plus ( 10 , ChronoUnit .SECONDS )
183
191
: nextIdealTimestamp ;
184
192
}
185
-
186
- final TimeDuration delayUntilNextExecution = TimeDuration.fromCurrent( this.nextScheduledCheck );
187
-
188
- executorService.schedule( new PeriodicCheck(), delayUntilNextExecution.asMillis(), TimeUnit.MILLISECONDS );
189
-
190
- LOGGER.trace( SessionLabel.VERSIONCHECK_SESSION_LABEL, () -> "scheduled next check execution at " + JavaHelper.toIsoDate( nextScheduledCheck )
191
- + " in " + delayUntilNextExecution.asCompactString() );
192
-
193
- */
194
193
}
195
194
196
195
private class PeriodicCheck implements Runnable
0 commit comments