reschke commented on code in PR #1146:
URL: https://github.com/apache/jackrabbit-oak/pull/1146#discussion_r1363463562


##########
oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionableState.java:
##########
@@ -285,8 +287,32 @@ private void restoreFrozen(@NotNull NodeBuilder frozen,
                                @NotNull NodeBuilder dest,
                                @NotNull VersionSelector selector)
             throws RepositoryException, CommitFailedException {
-        // 15.7.2 Restoring Type and Identifier
-        restoreFrozenTypeAndUUID(frozen, dest);
+        //OAK-9459: if the NodeState is not empty, retrieve OPVs before 
restoring types to avoid constraint violations
+        boolean frozenTypeRestored = false;
+        if (!dest.hasProperty(JCR_PRIMARYTYPE)) {
+            // empty NodeState
+            // 15.7.2 Restoring Type and Identifier
+            restoreFrozenTypeAndUUID(frozen, dest);
+            frozenTypeRestored = true;
+        }
+        HashMap<PropertyState, Integer> opvs = new HashMap<>();
+        for (PropertyState p : dest.getProperties()) {
+            String propName = p.getName();
+            if (BASIC_PROPERTIES.contains(propName)) {
+                continue;

Review Comment:
   I find code that uses "continue" usually harder to read. In this case, it 
seems putting the remainder of the block into an "if" wrapper works as well.
   
   But yes, in the meantime I realized it's old code, just was moved around.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to