jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Dürig (JIRA) <j...@apache.org>
Subject [jira] Commented: (JCR-2293) PathNotFoundException but item exists
Date Mon, 07 Sep 2009 15:20:57 GMT

    [ https://issues.apache.org/jira/browse/JCR-2293?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12752165#action_12752165
] 

Michael Dürig commented on JCR-2293:
------------------------------------

The described behavior can be seen as 'works as intended' given that there might be a race
between the two sessions in this test case. Things are a bit different when observation comes
into play however: When session2 calls getItem on the path of a NODE_ADDED event, the same
behavior can be observed. This doesn't seem correct to me. After all, the observation events
that a node at the given path has just been added:

interface WaitableEventListener extends EventListener {
    public void waitForEvent() throws InterruptedException, RepositoryException;
}

public void testJCR_2293() throws RepositoryException, InterruptedException {
    final String parentPath = testNode.getPath();
    final String folderName = "folder_" + System.currentTimeMillis();
    Session session = getHelper().getReadWriteSession();

    final Session session2 = getHelper().getReadOnlySession();
    session2.getItem(parentPath);  // removing this line makes the failure go away

    WaitableEventListener eventListener = new WaitableEventListener() {
        private RepositoryException failure;

        public synchronized void onEvent(final EventIterator events) {
            try {
                while (events.hasNext()) {
                    Event event = events.nextEvent();
                    Item item2 = session2.getItem(event.getPath());
                    assertEquals(parentPath + "/" + folderName, item2.getPath());
                }
            }
            catch (RepositoryException e) {
                failure = e;
            }
            finally {
                notifyAll();
            }
        }

        public synchronized void waitForEvent() throws InterruptedException,
                        RepositoryException {
            this.wait();
            if (failure != null) {
                throw failure;
            }
        }
    };

    session.getWorkspace().getObservationManager()
            .addEventListener(eventListener, Event.NODE_ADDED,
                                             parentPath, true, null, null, false);

    Node parent = (Node) session.getItem(parentPath);
    Node toDelete = parent.addNode(folderName, "nt:folder");
    parent.save();

    try {
        eventListener.waitForEvent();
    }
    finally {
        toDelete.remove();
        parent.save();
        assertFalse(parent.hasNode(folderName));
    }
}




> PathNotFoundException but item exists
> -------------------------------------
>
>                 Key: JCR-2293
>                 URL: https://issues.apache.org/jira/browse/JCR-2293
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-jcr2spi
>    Affects Versions: 1.5.7, 2.0.0
>            Reporter: Michael Dürig
>
> The following test case (for jcr2spi) throws a PathNotFoundException for an item which
exists. It does not throw if the marked line below is commented out. 
> public void testBug24687() throws RepositoryException {
>     String parentPath = testNode.getPath();
>     String folderName = "folder_" + System.currentTimeMillis();
>     Session session = getHelper().getReadWriteSession();
>     Session session2 = getHelper().getReadOnlySession();
>     session2.getItem(parentPath);  // removing this line makes the failure go away
>     Node parent = (Node) session.getItem(parentPath);
>     Node toDelete = parent.addNode(folderName, "nt:folder");
>     parent.save();
>     try {
>         Item item2 = session2.getItem(parentPath + "/" + folderName);  // wrongly throws
PathNotFoundException
>         assertEquals(parentPath + "/" + folderName, item2.getPath());
>     }
>     finally {
>         toDelete.remove();
>         parent.save();
>         assertFalse(parent.hasNode(folderName));
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message