jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Julian Reschke (Created) (JIRA)" <j...@apache.org>
Subject [jira] [Created] (JCR-3105) NPE when versioning operations are concurrent
Date Mon, 10 Oct 2011 17:40:29 GMT
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


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

        

Mime
View raw message