You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:40:02 UTC

[sling-org-apache-sling-hc-support] 15/31: Correctly free service references

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

rombert pushed a commit to annotated tag org.apache.sling.hc.support-1.0.4
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hc-support.git

commit ed9b0ef04c9821fa21abdae4749056a45e779d70
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Sep 2 14:47:08 2013 +0000

    Correctly free service references
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/healthcheck/healthchecks@1519454 13f79535-47bb-0310-9956-ffa450edef68
---
 .../hc/healthchecks/impl/CompositeHealthCheck.java | 58 ++++++++++++----------
 1 file changed, 31 insertions(+), 27 deletions(-)

diff --git a/src/main/java/org/apache/sling/hc/healthchecks/impl/CompositeHealthCheck.java b/src/main/java/org/apache/sling/hc/healthchecks/impl/CompositeHealthCheck.java
index 57a4a63..4996e44 100644
--- a/src/main/java/org/apache/sling/hc/healthchecks/impl/CompositeHealthCheck.java
+++ b/src/main/java/org/apache/sling/hc/healthchecks/impl/CompositeHealthCheck.java
@@ -71,37 +71,41 @@ public class CompositeHealthCheck implements HealthCheck {
     @Override
     public Result execute() {
         final FormattingResultLog resultLog = new FormattingResultLog();
-        final List<HealthCheck> checks = new HealthCheckFilter(bundleContext).getTaggedHealthChecks(filterTags);
-        if(checks.size() == 0) {
-            resultLog.warn("HealthCheckFilter returns no HealthCheck for tags {}", Arrays.asList(filterTags));
-            return new Result(resultLog);
-        }
-
-        int executed = 0;
-        resultLog.debug("Executing {} HealthCheck selected by the {} tags", checks.size(), Arrays.asList(filterTags));
-        int failures = 0;
-        for(HealthCheck hc : checks) {
-            if(hc == this) {
-                resultLog.info("Cowardly forfeiting execution of this HealthCheck in an infinite loop, ignoring it");
-                continue;
+        final HealthCheckFilter filter = new HealthCheckFilter(bundleContext);
+        try {
+            final List<HealthCheck> checks = filter.getTaggedHealthChecks(filterTags);
+            if(checks.size() == 0) {
+                resultLog.warn("HealthCheckFilter returns no HealthCheck for tags {}", Arrays.asList(filterTags));
+                return new Result(resultLog);
             }
-            resultLog.debug("Executing {}", hc);
-            executed++;
-            final Result sub = hc.execute();
-            if(!sub.isOk()) {
-                failures++;
-            }
-            for(ResultLog.Entry e : sub) {
-                resultLog.add(e);
+
+            int executed = 0;
+            resultLog.debug("Executing {} HealthCheck selected by the {} tags", checks.size(), Arrays.asList(filterTags));
+            int failures = 0;
+            for(HealthCheck hc : checks) {
+                if(hc == this) {
+                    resultLog.info("Cowardly forfeiting execution of this HealthCheck in an infinite loop, ignoring it");
+                    continue;
+                }
+                resultLog.debug("Executing {}", hc);
+                executed++;
+                final Result sub = hc.execute();
+                if(!sub.isOk()) {
+                    failures++;
+                }
+                for(ResultLog.Entry e : sub) {
+                    resultLog.add(e);
+                }
             }
-        }
 
-        if(failures == 0) {
-            resultLog.debug("{} HealthCheck executed, all ok", executed);
-        } else {
-            resultLog.warn("{} HealthCheck executed, {} failures", executed, failures);
+            if(failures == 0) {
+                resultLog.debug("{} HealthCheck executed, all ok", executed);
+            } else {
+                resultLog.warn("{} HealthCheck executed, {} failures", executed, failures);
+            }
+        } finally {
+            filter.dispose();
         }
-
         return new Result(resultLog);
     }
 }
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.