reschke commented on code in PR #1146:
URL: https://github.com/apache/jackrabbit-oak/pull/1146#discussion_r1367012810
##########
oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionableState.java:
##########
@@ -285,43 +287,68 @@ 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);
- // 15.7.3 Restoring Properties
- for (PropertyState p : frozen.getProperties()) {
- if (BASIC_FROZEN_PROPERTIES.contains(p.getName())) {
- // ignore basic frozen properties we restored earlier
- continue;
- }
- int action = getOPV(dest, p);
- if (action == COPY || action == VERSION) {
- dest.setProperty(p);
- }
+ //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;
}
+ Map<PropertyState, Integer> opvs = new HashMap<>();
for (PropertyState p : dest.getProperties()) {
String propName = p.getName();
- if (BASIC_PROPERTIES.contains(propName)) {
- continue;
- }
- if (frozen.hasProperty(propName)) {
- continue;
+ if (!BASIC_PROPERTIES.contains(propName) &&
!frozen.hasProperty(propName)) {
+ int action = getOPV(dest, p);
+ switch (action) {
Review Comment:
can we just change that to
action != IGNORE
?
Or, actually, wouldn't it be clearer just to store all OPV states here?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]