return the precise scheduled execution time for timers (#3182)

When writing tests and mocking time, it can be important that
execution_time match _exactly_ with what was sent to reschedule().
When re-calculating based on now and the expected remaining delay,
this might be off by a few milliseconds. We have the exact time
that was requested already, so might as well use it.

Signed-off-by: Cody Cutrer <cody@cutrer.us>
pull/3184/head
Cody Cutrer 2022-11-29 10:25:53 -07:00 committed by GitHub
parent af3738487c
commit d96e5d5bc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 2 deletions

View File

@ -13,7 +13,6 @@
package org.openhab.core.automation.module.script.internal.action;
import java.time.ZonedDateTime;
import java.util.concurrent.TimeUnit;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
@ -64,7 +63,7 @@ public class TimerImpl implements Timer {
@Override
public @Nullable ZonedDateTime getExecutionTime() {
return future.isCancelled() ? null : ZonedDateTime.now().plusNanos(future.getDelay(TimeUnit.NANOSECONDS));
return future.isCancelled() ? null : future.getScheduledTime();
}
@Override