mbaedke commented on code in PR #1146: URL: https://github.com/apache/jackrabbit-oak/pull/1146#discussion_r1363607487
########## 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 don't care, so I'll remove the continue and and I think we should also turn the if-else if sequence into a switch. -- 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