Skip to content

Commit

Permalink
[innogysmarthome] Revert of openhab#8186 (openhab#8224)
Browse files Browse the repository at this point in the history
Revert of "Reconnect fix (isDone was never true, because the scheduled task is everytime currently running when the scheduleRestartClient method is executed)" because it causes too many requests when the servers aren't available.

Signed-off-by: Sven Strohschein <[email protected]>
  • Loading branch information
Novanic authored and andrewfg committed Aug 31, 2020
1 parent ed8569d commit f48ef06
Showing 1 changed file with 2 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,9 @@ public void onAccessTokenResponse(final AccessTokenResponse credential) {
* @param seconds
*/
private synchronized void scheduleRestartClient(final long seconds) {
@Nullable final ScheduledFuture<?> localReinitJob = reinitJob;
final ScheduledFuture<?> localReinitJob = reinitJob;

if (localReinitJob != null && isAlreadyScheduled(localReinitJob)) {
if (localReinitJob != null && !localReinitJob.isDone()) {
logger.debug("Scheduling reinitialize in {} seconds - ignored: already triggered in {} seconds.", seconds,
localReinitJob.getDelay(TimeUnit.SECONDS));
return;
Expand Down Expand Up @@ -951,13 +951,4 @@ private void refreshAccessToken() {
logger.debug("Could not refresh tokens", e);
}
}

/**
* Checks if the job is already (re-)scheduled.
* @param job job to check
* @return true, when the job is already (re-)scheduled, otherwise false
*/
private static boolean isAlreadyScheduled(ScheduledFuture<?> job) {
return job.getDelay(TimeUnit.SECONDS) > 0;
}
}

0 comments on commit f48ef06

Please sign in to comment.