diff --git a/extensions/oidc-db-token-state-manager/deployment/src/test/java/io/quarkus/oidc/db/token/state/manager/MsSqlDbTokenStateManagerTest.java b/extensions/oidc-db-token-state-manager/deployment/src/test/java/io/quarkus/oidc/db/token/state/manager/MsSqlDbTokenStateManagerTest.java index 846e020bf35b1..632b0ed3139a3 100644 --- a/extensions/oidc-db-token-state-manager/deployment/src/test/java/io/quarkus/oidc/db/token/state/manager/MsSqlDbTokenStateManagerTest.java +++ b/extensions/oidc-db-token-state-manager/deployment/src/test/java/io/quarkus/oidc/db/token/state/manager/MsSqlDbTokenStateManagerTest.java @@ -1,10 +1,13 @@ package io.quarkus.oidc.db.token.state.manager; import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.junit.jupiter.api.condition.EnabledIfSystemProperty; import org.junit.jupiter.api.extension.RegisterExtension; import io.quarkus.test.QuarkusUnitTest; +// Becomes flaky in Github CI due to limited resources +@EnabledIfSystemProperty(named = "run-mssql-db-token-state-manager-test", disabledReason = "Insufficient GH CI resources", matches = "true") public class MsSqlDbTokenStateManagerTest extends AbstractDbTokenStateManagerTest { @RegisterExtension diff --git a/extensions/oidc-db-token-state-manager/runtime/src/main/java/io/quarkus/oidc/db/token/state/manager/runtime/OidcDbTokenStateManagerInitializer.java b/extensions/oidc-db-token-state-manager/runtime/src/main/java/io/quarkus/oidc/db/token/state/manager/runtime/OidcDbTokenStateManagerInitializer.java index 0f4fce54ddbf0..a6fd1a7678bdb 100644 --- a/extensions/oidc-db-token-state-manager/runtime/src/main/java/io/quarkus/oidc/db/token/state/manager/runtime/OidcDbTokenStateManagerInitializer.java +++ b/extensions/oidc-db-token-state-manager/runtime/src/main/java/io/quarkus/oidc/db/token/state/manager/runtime/OidcDbTokenStateManagerInitializer.java @@ -11,6 +11,7 @@ import org.jboss.logging.Logger; +import io.quarkus.runtime.ShutdownEvent; import io.quarkus.runtime.StartupEvent; import io.smallrye.mutiny.Uni; import io.vertx.core.Handler; @@ -27,6 +28,7 @@ public class OidcDbTokenStateManagerInitializer { * Extra 30 seconds before we delete expired tokens. */ private static final long EXPIRED_EXTRA_GRACE = 30; + private static volatile Long timerId = null; void initialize(@Observes StartupEvent event, OidcDbTokenStateManagerRunTimeConfig config, Vertx vertx, Pool pool, OidcDbTokenStateManagerInitializerProperties initializerProps) { @@ -36,8 +38,14 @@ void initialize(@Observes StartupEvent event, OidcDbTokenStateManagerRunTimeConf periodicallyDeleteExpiredTokens(vertx, pool, config.deleteExpiredDelay().toMillis()); } + void shutdown(@Observes ShutdownEvent event, Vertx vertx) { + if (timerId != null) { + vertx.cancelTimer(timerId); + } + } + private static void periodicallyDeleteExpiredTokens(Vertx vertx, Pool pool, long delayBetweenChecks) { - vertx + timerId = vertx .setPeriodic(5000, delayBetweenChecks, new Handler() { private final AtomicBoolean deleteInProgress = new AtomicBoolean(false);