Skip to content

Commit cc79edd

Browse files
committed
fix version check debug code
1 parent 87b4d24 commit cc79edd

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

server/src/main/java/password/pwm/svc/version/VersionCheckService.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -161,36 +161,35 @@ private void scheduleNextCheck()
161161
return;
162162
}
163163

164-
this.nextScheduledCheck = Instant.now().plus( 1, ChronoUnit.MINUTES );
165-
executorService.schedule( new PeriodicCheck(), 1, TimeUnit.MINUTES );
166-
167-
/*
168164
final VersionCheckInfoCache localCache = cacheHolder.getVersionCheckInfoCache();
169165

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+
{
170178
final TimeDuration idealDurationUntilNextCheck = localCache.getLastError() != null && localCache.getCurrentVersion() == null
171179
? settings.getCheckIntervalError()
172180
: settings.getCheckInterval();
173181

174182
if ( localCache.getLastCheckTimestamp() == null )
175183
{
176-
this.nextScheduledCheck = Instant.now().plus( 10, ChronoUnit.SECONDS );
184+
return Instant.now().plus( 10, ChronoUnit.SECONDS );
177185
}
178186
else
179187
{
180188
final Instant nextIdealTimestamp = localCache.getLastCheckTimestamp().plus( idealDurationUntilNextCheck.asDuration() );
181-
this.nextScheduledCheck = nextIdealTimestamp.isBefore( Instant.now() )
189+
return nextIdealTimestamp.isBefore( Instant.now() )
182190
? Instant.now().plus( 10, ChronoUnit.SECONDS )
183191
: nextIdealTimestamp;
184192
}
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-
*/
194193
}
195194

196195
private class PeriodicCheck implements Runnable

0 commit comments

Comments
 (0)