You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "Julian Reschke (Updated) (JIRA)" <ji...@apache.org> on 2011/10/11 09:54:29 UTC

[jira] [Updated] (JCR-3105) NPE when versioning operations are concurrent

     [ https://issues.apache.org/jira/browse/JCR-3105?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julian Reschke updated JCR-3105:
--------------------------------

    Attachment: JCR-3105.patch

proposed patch
                
> NPE when versioning operations are concurrent
> ---------------------------------------------
>
>                 Key: JCR-3105
>                 URL: https://issues.apache.org/jira/browse/JCR-3105
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-core
>            Reporter: Julian Reschke
>         Attachments: JCR-3105.patch
>
>
> InternalVersionManagerBase.getParentNode occasionally throws an NPE:
>     protected static NodeStateEx getParentNode(NodeStateEx parent, String uuid, Name interNT)
>             throws RepositoryException {
>         NodeStateEx n = parent;
>         for (int i = 0; i < 3; i++) {
>             Name name = getName(uuid.substring(i * 2, i * 2 + 2));
>             if (n.hasNode(name)) {
>                 n = n.getNode(name, 1);
>                 assert n != null;
>             } else if (interNT != null) {
>                 n.addNode(name, interNT, null, false);
>                 n.store();
>                 n = n.getNode(name, 1);
>                 assert n != null;
>             } else {
>                 return null;
>             }
>         }
>         return n;
>     }
> Apparently getNode occasionally returns null due to race conditions.
> Changing the code to what's below appears to fix it:
>     protected static NodeStateEx getParentNode(NodeStateEx parent, String uuid, Name interNT)
>             throws RepositoryException {
>         NodeStateEx n = parent;
>         for (int i = 0; i < 3; i++) {
>             Name name = getName(uuid.substring(i * 2, i * 2 + 2));
>             NodeStateEx n2 = n.getNode(name, 1);
>             if (n2 != null) {
>                 n = n2;
>             } else if (interNT != null) {
>                 n2 = n.addNode(name, interNT, null, false);
>                 n.store();
>                 n = n2;
>             } else {
>                 return null;
>             }
>         }
>         return n;
>     }
> (but likely moves the race condition somewhere else)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira