You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by kw...@apache.org on 2021/01/27 10:21:42 UTC

[sling-org-apache-sling-jcr-packageinit] 12/25: SLING-8222 - adjusting cases to reflect valid cases on restart when hashes might vary

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

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

commit eb3ccfd2a8efe8af8cc5c6c9ea9f3b71d9e1c54f
Author: Dominik Suess <su...@adobe.com>
AuthorDate: Thu Jan 17 13:38:47 2019 +0100

    SLING-8222 - adjusting cases to reflect valid cases on restart when hashes might vary
---
 .../impl/ExecutionPlanRepoInitializer.java         | 24 ++++++++++++++--------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/main/java/org/apache/sling/jcr/packageinit/impl/ExecutionPlanRepoInitializer.java b/src/main/java/org/apache/sling/jcr/packageinit/impl/ExecutionPlanRepoInitializer.java
index 9d5346f..ed61786 100644
--- a/src/main/java/org/apache/sling/jcr/packageinit/impl/ExecutionPlanRepoInitializer.java
+++ b/src/main/java/org/apache/sling/jcr/packageinit/impl/ExecutionPlanRepoInitializer.java
@@ -81,8 +81,8 @@ public class ExecutionPlanRepoInitializer implements SlingRepositoryInitializer
     private void activate(BundleContext context, Config config) throws FileNotFoundException, IOException {
         List<String> epCandidates = Arrays.asList(config.executionplans());
         if (!epCandidates.isEmpty()) {
-            if(StringUtils.isEmpty(config.statusfilepath())) {
-                // if no  path is configured lookup default file in bundledata
+            if (StringUtils.isEmpty(config.statusfilepath())) {
+                // if no path is configured lookup default file in bundledata
                 statusFile = context.getDataFile(EXECUTEDPLANS_FILE);
             } else {
                 Path statusFilePath = Paths.get(config.statusfilepath());
@@ -116,22 +116,23 @@ public class ExecutionPlanRepoInitializer implements SlingRepositoryInitializer
         // iterate over candidates and crosscheck next found hash
         while (candidateIt.hasNext()) {
             String candidate = candidateIt.next();
-            if (!executedHashesIt.hasNext()) {
+            boolean foundDifference = false;
+            if (!executedHashesIt.hasNext() || foundDifference) {
                 // if no further hashes are present add candidate
                 // (will iterate over rest and add rest)
                 executionPlans.add(candidate);
             } else {
-                // if another hash was found check if it matches the
-                // next candidate
+                // another hash was found & no difference 
                 Integer executedHash = executedHashesIt.next();
                 if (isCandidateProcessed(candidate, executedHash)) {
                     // already processed so no need to add - check
                     // next plan
                     continue;
                 } else {
-                    String msg = "Different content installed then configured - repository needs to be reset.";
-                    logger.error(msg);
-                    throw new IllegalStateException(msg);
+                    executionPlans.add(candidate);
+                    String msg = "Found difference in hashed executionplans - queueing executionplan for processing.";
+                    logger.info(msg);
+                    foundDifference = true;
                 }
             }
         }
@@ -161,7 +162,12 @@ public class ExecutionPlanRepoInitializer implements SlingRepositoryInitializer
                         builder.load(new ByteArrayInputStream(plan.getBytes("UTF-8")));
                         builder.with(session);
                         ExecutionPlan xplan = builder.execute();
-                        logger.info("executionplan executed with {} entries", xplan.getTasks().size());
+                        if (xplan.getTasks().size() > 0) {
+                            logger.info("executionplan executed with {} entries", xplan.getTasks().size());
+                        } else {
+                            logger.info("No tasks found in executionplan - no additional packages installed.");
+                        }
+                        
                         // save hashes to file for crosscheck on subsequent startup to avoid double processing
                         writer.write(String.valueOf(plan.hashCode()));
                         writer.newLine();