This is an automated email from the ASF dual-hosted git repository.

stefanegli pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-event.git


The following commit(s) were added to refs/heads/master by this push:
     new c8b1d9f  Fix infinite recursion issue: SLING-11918 (#31)
c8b1d9f is described below

commit c8b1d9f0fd950028c9b3b29fcc0e6008a8fcb37e
Author: Patrique Legault <[email protected]>
AuthorDate: Tue Jul 11 05:45:26 2023 -0400

    Fix infinite recursion issue: SLING-11918 (#31)
    
    * Removing infinite loop
    
    * Adding retry count in GaugeSupport
    
    * Update 
src/main/java/org/apache/sling/event/impl/jobs/stats/GaugeSupport.java
    
    Co-authored-by: stefan-egli <[email protected]>
    
    ---------
    
    Co-authored-by: stefan-egli <[email protected]>
---
 .../org/apache/sling/event/impl/jobs/stats/GaugeSupport.java     | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git 
a/src/main/java/org/apache/sling/event/impl/jobs/stats/GaugeSupport.java 
b/src/main/java/org/apache/sling/event/impl/jobs/stats/GaugeSupport.java
index a73dca8..b2cb896 100644
--- a/src/main/java/org/apache/sling/event/impl/jobs/stats/GaugeSupport.java
+++ b/src/main/java/org/apache/sling/event/impl/jobs/stats/GaugeSupport.java
@@ -21,6 +21,8 @@ package org.apache.sling.event.impl.jobs.stats;
 import com.codahale.metrics.Gauge;
 import com.codahale.metrics.MetricRegistry;
 import org.apache.sling.event.jobs.Statistics;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.util.HashMap;
 import java.util.HashSet;
@@ -48,6 +50,8 @@ class GaugeSupport {
     private final Set<String> gaugeMetricNames = new HashSet<>();
     private final String queueName;
 
+    private Logger logger = LoggerFactory.getLogger(this.getClass());
+
     /**
      * Create a new GaugeSupport instance for the global queue.
      *
@@ -150,8 +154,11 @@ class GaugeSupport {
             metricRegistry.register(metricName, value);
             gaugeMetricNames.add(metricName);
         } catch (IllegalArgumentException e) {
-            if (queueName != null) {
+            if (queueName != null && count <= 10) {
+                logger.debug("Failed to register suffix {} for the queue {}, 
attempt {}, retrying.", suffix, queueName, count, e);
                 registerWithSuffix(suffix, count + 1, value);
+            } else {
+                logger.error("Failed to register suffix {} for the queue {}, 
attempt {}, giving up.", suffix, queueName, count, e);
             }
         }
     }

Reply via email to