Skip to content

Commit

Permalink
Merge pull request #36366 from michalvavrik/feature/ref-oidc-db-token…
Browse files Browse the repository at this point in the history
…-state-manager

OIDC Db Token State Manager - disable MSSQL test due to limited Github CI resources and cancel timer on shutdown
  • Loading branch information
sberyozkin authored Oct 9, 2023
2 parents 2700890 + 6133803 commit f64aaf4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -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<Long>() {

private final AtomicBoolean deleteInProgress = new AtomicBoolean(false);
Expand Down

0 comments on commit f64aaf4

Please sign in to comment.