From 74a8bc871bc3ed40fc08ea634ab82e6a9709ea1c Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Fri, 17 Jan 2025 09:54:57 +1100 Subject: [PATCH] Issue #12705 fix orphan session checks (#12708) --- .../jetty/session/AbstractSessionDataStore.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/jetty-core/jetty-session/src/main/java/org/eclipse/jetty/session/AbstractSessionDataStore.java b/jetty-core/jetty-session/src/main/java/org/eclipse/jetty/session/AbstractSessionDataStore.java index 578941a24dd9..ea1ce727758e 100644 --- a/jetty-core/jetty-session/src/main/java/org/eclipse/jetty/session/AbstractSessionDataStore.java +++ b/jetty-core/jetty-session/src/main/java/org/eclipse/jetty/session/AbstractSessionDataStore.java @@ -292,19 +292,20 @@ public Set getExpired(Set candidates) // OTHER contexts that expired a very long time ago (ie not being actively // managed by any node). As these sessions are not for our context, we // can't load them, so they must just be forcibly deleted. - try + + if (now > (_lastOrphanSweepTime + TimeUnit.SECONDS.toMillis(10 * _gracePeriodSec))) { - if (now > (_lastOrphanSweepTime + TimeUnit.SECONDS.toMillis(10 * _gracePeriodSec))) + try { if (LOG.isDebugEnabled()) LOG.debug("Cleaning orphans at {}, last sweep at {}", now, _lastOrphanSweepTime); - + cleanOrphans(now - TimeUnit.SECONDS.toMillis(10 * _gracePeriodSec)); } - } - finally - { - _lastOrphanSweepTime = now; + finally + { + _lastOrphanSweepTime = now; + } } return expired;