-
Notifications
You must be signed in to change notification settings - Fork 69
JCRVLT-767: vlt: potential incorrect identifier comparison #348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 4 commits
931ceef
100024c
864914e
073c891
223bb00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -989,8 +989,19 @@ private void removeReferences(@NotNull Node node) throws ReferentialIntegrityExc | |
| VersioningState vs = new VersioningState(stack, node); | ||
| Node updatedNode = null; | ||
| Optional<String> identifier = ni.getIdentifier(); | ||
|
|
||
| boolean isUuidProtected = false; | ||
| if (node.hasProperty(Property.JCR_UUID)) { | ||
| isUuidProtected = node.getProperty(Property.JCR_UUID).getDefinition().isProtected(); | ||
| } else if (! session.getRepository().getDescriptor(Repository.REP_NAME_DESC).contains("Oak")) { | ||
| // workaround for non-Oak repos that may not be able to add | ||
| // mixin:referencable *after* setting jcr:uuid | ||
| isUuidProtected = true; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The original idea was to encapsulate impl specific differences in https://github.com/apache/jackrabbit-filevault/blob/master/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/spi/ServiceProvider.java.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the pointer; let's do more research on the "setting of jcr:uuid" first, and the outcome of that would inform what information we would want to add there. |
||
| } | ||
|
|
||
| // try to set uuid via sysview import if it differs from existing one | ||
| if (identifier.isPresent() && !node.getIdentifier().equals(identifier.get()) && !"rep:root".equals(ni.getPrimaryType().orElse(""))) { | ||
| if (identifier.isPresent() && isUuidProtected && !node.getIdentifier().equals(identifier.get()) | ||
| && !"rep:root".equals(ni.getPrimaryType().orElse(""))) { | ||
| long startTime = System.currentTimeMillis(); | ||
| String previousIdentifier = node.getIdentifier(); | ||
| log.debug("Node stashing for {} starting, existing identifier: {}, new identifier: {}, import mode: {}", | ||
|
|
@@ -1047,8 +1058,38 @@ private void removeReferences(@NotNull Node node) throws ReferentialIntegrityExc | |
| } | ||
| // add remaining mixins (for all import modes) | ||
| for (String mixin : newMixins) { | ||
| Property uuidProp = null; | ||
| vs.ensureCheckedOut(); | ||
| node.addMixin(mixin); | ||
|
|
||
| if (mixin.equals("mix:referenceable") && identifier.isPresent()) { | ||
| // if this is mix:ref and ni specifies an identifier, | ||
| // try to set it | ||
| try { | ||
| uuidProp = node.setProperty(Property.JCR_UUID, identifier.get()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isn't the uuid already set through the sysview import?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought we get here in case we skipped that...? |
||
| } catch (RepositoryException ex) { | ||
| log.debug("tried to set jcr:uuid to {} before adding mix:referenceable failed, continuing", ex); | ||
| } | ||
|
|
||
| try { | ||
| node.addMixin(mixin); | ||
| } catch (RepositoryException ex) { | ||
| // try to add the mixin; this fails with classic | ||
| // jackrabbit, so undo the change for jcr:uuid and retry | ||
| if (uuidProp != null) { | ||
| log.debug( | ||
| "failed to add mix:referenceable after setting jcr:uuid, retrying without (uuid will be lost)", | ||
| ex); | ||
| // retry once after removing jcr:uuid | ||
| uuidProp.remove(); | ||
| node.addMixin(mixin); | ||
| } else { | ||
| throw ex; | ||
| } | ||
| } | ||
| } else { | ||
| node.addMixin(mixin); | ||
| } | ||
|
|
||
| updatedNode = node; | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why else if? Shouldn't this also overwrite isUuidProtected from line 995 potentially?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good question; tests passed with Jackrabbit; will have another look
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might have to do with https://jackrabbit.apache.org/oak/docs/differences.html#Identifiers - but code is unclear and needs fixing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should better wirh 223bb00