[java-shib-profile] branch main updated: JSPROF-4 - Limit heap usage in loop detection
Scott Cantor
cantor.2 at osu.edu
Mon Dec 4 15:30:19 UTC 2023
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-shib-profile.
View the commit online:
http://git.shibboleth.net/view/?p=java-shib-profile.git;a=commit;h=bbb2d45a004135527b3b06f7daa51255d85ec310
The following commit(s) were added to refs/heads/main by this push:
new bbb2d45 JSPROF-4 - Limit heap usage in loop detection
bbb2d45 is described below
commit bbb2d45a004135527b3b06f7daa51255d85ec310
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Dec 4 10:30:16 2023 -0500
JSPROF-4 - Limit heap usage in loop detection
https://shibboleth.atlassian.net/browse/JSPROF-4
Switch to private registry for isolation.
Add a remove call any time the Meter trips.
---
.../profile/context/logic/LoopDetectionPredicate.java | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/shib-profile-api/src/main/java/net/shibboleth/profile/context/logic/LoopDetectionPredicate.java b/shib-profile-api/src/main/java/net/shibboleth/profile/context/logic/LoopDetectionPredicate.java
index 179591b..66b4ac5 100644
--- a/shib-profile-api/src/main/java/net/shibboleth/profile/context/logic/LoopDetectionPredicate.java
+++ b/shib-profile-api/src/main/java/net/shibboleth/profile/context/logic/LoopDetectionPredicate.java
@@ -20,7 +20,6 @@ import java.util.function.Function;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.opensaml.core.metrics.MetricsSupport;
import org.opensaml.profile.context.ProfileRequestContext;
import org.slf4j.Logger;
@@ -46,6 +45,9 @@ public class LoopDetectionPredicate extends AbstractRelyingPartyPredicate {
/** Class logger. */
@Nonnull private final Logger log = LoggerFactory.getLogger(LoopDetectionPredicate.class);
+ /** Private registry to isolate timers. */
+ @Nonnull private final MetricRegistry privateRegistry;
+
/** Count to trigger warning. */
private long threshold;
@@ -57,6 +59,7 @@ public class LoopDetectionPredicate extends AbstractRelyingPartyPredicate {
/** Constructor. */
public LoopDetectionPredicate() {
+ privateRegistry = new MetricRegistry();
threshold = 20;
relyingPartyMap = CollectionSupport.emptyMap();
usernameLookupStrategy = FunctionSupport.constant(null);
@@ -106,12 +109,8 @@ public class LoopDetectionPredicate extends AbstractRelyingPartyPredicate {
if (meterName != null) {
meterName = MetricRegistry.name("net.shibboleth.idp.loopDetection", meterName,
username.replace(".",""));
- final MetricRegistry registry = MetricsSupport.getMetricRegistry();
- if (registry == null) {
- log.error("MetricRegistry was unavailable");
- return false;
- }
- final Meter meter = registry.meter(meterName,
+
+ final Meter meter = privateRegistry.meter(meterName,
new MetricSupplier<Meter>() {
public Meter newMetric() {
return new Meter(new SlidingTimeWindowMovingAverages());
@@ -121,6 +120,7 @@ public class LoopDetectionPredicate extends AbstractRelyingPartyPredicate {
final double rate = meter.getOneMinuteRate();
if (rate > threshold) {
log.warn("Meter {} rate of {} exceeded threshold of {}", meterName, rate, threshold);
+ privateRegistry.remove(meterName);
return true;
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list