reschke commented on code in PR #1146:
URL: https://github.com/apache/jackrabbit-oak/pull/1146#discussion_r1361934632
##########
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<>();
Review Comment:
```suggestion
Map<PropertyState, Integer> opvs = new HashMap<>();
```
##########
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:
Can we change the logic not to use "continue"?
--
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]