You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by en...@apache.org on 2020/09/16 17:20:31 UTC
[sling-org-apache-sling-jcr-contentloader] branch master updated:
SLING-9734 Incorporate changes from code review feedback.
This is an automated email from the ASF dual-hosted git repository.
enorman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentloader.git
The following commit(s) were added to refs/heads/master by this push:
new 13713b4 SLING-9734 Incorporate changes from code review feedback.
13713b4 is described below
commit 13713b4ba5e9711c1b4644aa2eff6ada22392fb2
Author: Eric Norman <en...@apache.org>
AuthorDate: Wed Sep 16 10:20:20 2020 -0700
SLING-9734 Incorporate changes from code review feedback.
---
bnd.bnd | 2 +-
.../contentloader/hc/BundleContentLoadedCheck.java | 34 ++++++++++++----------
2 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/bnd.bnd b/bnd.bnd
index f673c81..cb330c5 100644
--- a/bnd.bnd
+++ b/bnd.bnd
@@ -8,5 +8,5 @@ Bundle-Category:\
@org.apache.sling.jcr.contentparser-*.jar!/org/apache/sling/jcr/contentparser/impl/JsonTicksConverter.class
# healthcheck support is optional
- Import-Package: org.apache.felix.hc.api;resolution:=optional,\
+Import-Package: org.apache.felix.hc.api;resolution:=optional,\
*
diff --git a/src/main/java/org/apache/sling/jcr/contentloader/hc/BundleContentLoadedCheck.java b/src/main/java/org/apache/sling/jcr/contentloader/hc/BundleContentLoadedCheck.java
index c188706..d58d5f8 100644
--- a/src/main/java/org/apache/sling/jcr/contentloader/hc/BundleContentLoadedCheck.java
+++ b/src/main/java/org/apache/sling/jcr/contentloader/hc/BundleContentLoadedCheck.java
@@ -96,7 +96,7 @@ public class BundleContentLoadedCheck implements HealthCheck {
this.bundleContext = bundleContext;
this.includesRegex = Pattern.compile(config.includesRegex());
String excludesRegex2 = config.excludesRegex();
- this.excludesRegex = (excludesRegex2 != null && !excludesRegex2.isEmpty()) ? Pattern.compile(excludesRegex2) : null;
+ this.excludesRegex = (excludesRegex2 != null && !excludesRegex2.isEmpty()) ? Pattern.compile(excludesRegex2) : null;
this.useCriticalForNotLoaded = config.useCriticalForNotLoaded();
LOG.debug("Activated bundle content loaded HC for includesRegex={} excludesRegex={}% useCriticalForNotLoaded={}", includesRegex, excludesRegex, useCriticalForNotLoaded);
}
@@ -115,12 +115,12 @@ public class BundleContentLoadedCheck implements HealthCheck {
Session metadataSession = null;
try {
- metadataSession = repository.loginAdministrative(null);
-
- BundleHelper bundleHelper = new ContentLoaderService();
-
+ metadataSession = repository.loginAdministrative(null);
+
+ BundleHelper bundleHelper = new ContentLoaderService();
+
for (Bundle bundle : bundles) {
- String bundleSymbolicName = bundle.getSymbolicName();
+ String bundleSymbolicName = bundle.getSymbolicName();
if (!includesRegex.matcher(bundleSymbolicName).matches()) {
LOG.debug("Bundle {} not matched by {}", bundleSymbolicName, includesRegex);
continue;
@@ -131,20 +131,20 @@ public class BundleContentLoadedCheck implements HealthCheck {
countExcluded ++;
continue;
}
-
+
// check if bundle has initial content
final Iterator<PathEntry> pathIter = PathEntry.getContentPaths(bundle);
if (pathIter == null) {
log.debug("Bundle {} has no initial content", bundleSymbolicName);
} else {
- relevantBundlesCount++;
-
+ relevantBundlesCount++;
+
// check if the content has already been loaded
final Map<String, Object> bundleContentInfo = bundleHelper.getBundleContentInfo(metadataSession, bundle, false);
// if we don't get an info, someone else is currently loading
if (bundleContentInfo == null) {
- notLoadedCount++;
+ notLoadedCount++;
String msg = "Not loaded bundle {} {}";
Object[] msgObjs = new Object[] {bundle.getBundleId(), bundleSymbolicName};
LOG.debug(msg, msgObjs);
@@ -154,7 +154,7 @@ public class BundleContentLoadedCheck implements HealthCheck {
log.warn(msg, msgObjs);
}
} else {
- try {
+ try {
final boolean contentAlreadyLoaded = ((Boolean) bundleContentInfo.get(ContentLoaderService.PROPERTY_CONTENT_LOADED)).booleanValue();
boolean isBundleUpdated = false;
Calendar lastLoadedAt = (Calendar) bundleContentInfo.get(ContentLoaderService.PROPERTY_CONTENT_LOADED_AT);
@@ -173,19 +173,21 @@ public class BundleContentLoadedCheck implements HealthCheck {
} else {
log.warn(msg, msgObjs);
}
- }
- } finally {
+ }
+ } finally {
bundleHelper.unlockBundleContentInfo(metadataSession, bundle, false, null);
- }
+ }
}
}
}
} catch (RepositoryException t) {
- LOG.error("Unexpected error: " + t.getMessage(), t);
+ String msg = "Unexpected error: " + t.getMessage();
+ LOG.error(msg, t);
+ log.critical(msg);
} finally {
if (metadataSession != null) {
try {
- metadataSession.logout();
+ metadataSession.logout();
} catch (Exception t) {
LOG.error("Unable to log out of session: " + t.getMessage(), t);
}