You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by jo...@apache.org on 2025/09/09 11:51:40 UTC
(jackrabbit-oak) branch trunk updated: OAK-11894 resolve the IdentifierManager lazily (#2494)
This is an automated email from the ASF dual-hosted git repository.
joerghoh pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/trunk by this push:
new 94baba812c OAK-11894 resolve the IdentifierManager lazily (#2494)
94baba812c is described below
commit 94baba812ce76ff875253529b15f9d081a90d985
Author: Jörg Hoh <jo...@users.noreply.github.com>
AuthorDate: Tue Sep 9 13:51:35 2025 +0200
OAK-11894 resolve the IdentifierManager lazily (#2494)
* OAK-11894 resolve the IdentifierManager lazily
---
.../main/java/org/apache/jackrabbit/oak/jcr/xml/ImporterImpl.java | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImporterImpl.java b/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImporterImpl.java
index c60f54b9bc..7ed1f18e7c 100644
--- a/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImporterImpl.java
+++ b/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImporterImpl.java
@@ -23,6 +23,7 @@ import java.util.List;
import java.util.Set;
import java.util.Stack;
import java.util.UUID;
+import java.util.function.Supplier;
import javax.jcr.ImportUUIDBehavior;
import javax.jcr.ItemExistsException;
@@ -44,6 +45,7 @@ import org.apache.jackrabbit.oak.api.Tree;
import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.commons.PathUtils;
import org.apache.jackrabbit.oak.commons.collections.IterableUtils;
+import org.apache.jackrabbit.oak.commons.internal.function.Suppliers;
import org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate;
import org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate;
import org.apache.jackrabbit.oak.jcr.security.AccessManager;
@@ -578,7 +580,7 @@ public class ImporterImpl implements Importer {
* no modifications are performed
*/
private final IdentifierManager currentStateIdManager;
- private final IdentifierManager baseStateIdManager;
+ private final Supplier<IdentifierManager> baseStateIdManager;
/**
* Set of newly created uuid from nodes which are
@@ -590,7 +592,7 @@ public class ImporterImpl implements Importer {
private IdResolver(@NotNull Root root, @NotNull ContentSession contentSession) {
currentStateIdManager = new IdentifierManager(root);
- baseStateIdManager = new IdentifierManager(contentSession.getLatestRoot());
+ baseStateIdManager = Suppliers.memoize(() -> new IdentifierManager(contentSession.getLatestRoot()));
if (!root.hasPendingChanges()) {
importedUUIDs = new HashSet<String>();
@@ -604,7 +606,7 @@ public class ImporterImpl implements Importer {
private Tree getConflictingTree(@NotNull String id) {
//1. First check from base state that tree corresponding to
//this id exist
- Tree conflicting = baseStateIdManager.getTree(id);
+ Tree conflicting = baseStateIdManager.get().getTree(id);
if (conflicting == null && importedUUIDs != null) {
//1.a. Check if id is found in newly created nodes
if (importedUUIDs.contains(id)) {