You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by jo...@apache.org on 2024/03/09 17:03:02 UTC
(sling-org-apache-sling-jcr-repoinit) branch SLING-12264 created (now abdbe8b)
This is an automated email from the ASF dual-hosted git repository.
joerghoh pushed a change to branch SLING-12264
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-repoinit.git
at abdbe8b SLING-12264 only call save() if there's something to save
This branch includes the following new commits:
new abdbe8b SLING-12264 only call save() if there's something to save
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(sling-org-apache-sling-jcr-repoinit) 01/01: SLING-12264 only call save() if there's something to save
Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
joerghoh pushed a commit to branch SLING-12264
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-repoinit.git
commit abdbe8b67ffd360c6abdcc2fbfea61af1e11a835
Author: Joerg Hoh <jo...@apache.org>
AuthorDate: Sat Mar 9 18:02:52 2024 +0100
SLING-12264 only call save() if there's something to save
---
src/main/java/org/apache/sling/jcr/repoinit/impl/NodeVisitor.java | 4 +++-
.../org/apache/sling/jcr/repoinit/impl/RepositoryInitializer.java | 4 +++-
.../apache/sling/jcr/repoinit/impl/RepositoryInitializerFactory.java | 4 +++-
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/main/java/org/apache/sling/jcr/repoinit/impl/NodeVisitor.java b/src/main/java/org/apache/sling/jcr/repoinit/impl/NodeVisitor.java
index 8843f02..33c98a9 100644
--- a/src/main/java/org/apache/sling/jcr/repoinit/impl/NodeVisitor.java
+++ b/src/main/java/org/apache/sling/jcr/repoinit/impl/NodeVisitor.java
@@ -118,7 +118,9 @@ public class NodeVisitor extends DoNothingVisitor {
npv.visitSetProperties(sp);
}
try {
- session.save();
+ if (session.hasPendingChanges()) {
+ session.save();
+ }
} catch (Exception e) {
report(e, "Session.save failed: " + e);
}
diff --git a/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializer.java b/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializer.java
index d20c6e3..8d822ba 100644
--- a/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializer.java
+++ b/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializer.java
@@ -105,7 +105,9 @@ public class RepositoryInitializer implements SlingRepositoryInitializer {
}
log.info("Executing {} repoinit operations from {}", ops.size(), reference);
processor.apply(s, ops);
- s.save();
+ if (s.hasPendingChanges()) {
+ s.save();
+ }
} catch (IOException|RuntimeException|RepositoryException|RepoInitParsingException e) {
throw new RepoInitException("Error executing repoinit from " + reference, e);
}
diff --git a/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializerFactory.java b/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializerFactory.java
index f076dc9..f1d4f1f 100644
--- a/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializerFactory.java
+++ b/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializerFactory.java
@@ -185,7 +185,9 @@ public class RepositoryInitializerFactory implements SlingRepositoryInitializer
return retry.apply(() -> {
try {
processor.apply(session, ops);
- session.save();
+ if (session.hasPendingChanges()) {
+ session.save();
+ }
return new RetryableOperation.RetryableOperationResult(true,false,reference,null);
} catch (InvalidItemStateException|RepoInitException ex) {
// a retry makes sense, because this exception might be caused by an concurrent operation