Return-Path: X-Original-To: apmail-jackrabbit-dev-archive@www.apache.org Delivered-To: apmail-jackrabbit-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4916AD54C for ; Sun, 1 Jul 2012 16:13:00 +0000 (UTC) Received: (qmail 42826 invoked by uid 500); 1 Jul 2012 16:13:00 -0000 Delivered-To: apmail-jackrabbit-dev-archive@jackrabbit.apache.org Received: (qmail 42783 invoked by uid 500); 1 Jul 2012 16:13:00 -0000 Mailing-List: contact dev-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list dev@jackrabbit.apache.org Received: (qmail 42776 invoked by uid 99); 1 Jul 2012 16:13:00 -0000 Received: from issues-vm.apache.org (HELO issues-vm) (140.211.11.160) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 Jul 2012 16:13:00 +0000 Received: from isssues-vm.apache.org (localhost [127.0.0.1]) by issues-vm (Postfix) with ESMTP id B5FAF1418F1 for ; Sun, 1 Jul 2012 16:12:58 +0000 (UTC) Date: Sun, 1 Jul 2012 16:12:58 +0000 (UTC) From: "Unico Hommes (JIRA)" To: dev@jackrabbit.apache.org Message-ID: <1031671999.76634.1341159178749.JavaMail.jiratomcat@issues-vm> In-Reply-To: <1897995280.76561.1341155796183.JavaMail.jiratomcat@issues-vm> Subject: [jira] [Commented] (JCR-3368) Node#hasNode fails with RepositoryException because intermediate state cannot be retrieved when it should just return false MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/JCR-3368?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13404757#comment-13404757 ] Unico Hommes commented on JCR-3368: ----------------------------------- Did you have a look at the attached test case? I really think it should not throw this exception in this case. Note that if you change the session.getRootNode().hasNode("foo/bar"); in the test case to session.nodeExists("/foo/bar"); the test passes. This is because the session operation "nodeExists" directly calls ItemManager.nodeExists, which is implemented as follows: public boolean nodeExists(Path path) { try { sanityCheck(); NodeId id = hierMgr.resolveNodePath(path); return (id != null) && itemExists(id, path); } catch (RepositoryException re) { return false; } } Probably, here hierMgr.resolveNodePath(path) throws the same RepositoryException, but the difference is that it is caught and then returns false. > Node#hasNode fails with RepositoryException because intermediate state cannot be retrieved when it should just return false > --------------------------------------------------------------------------------------------------------------------------- > > Key: JCR-3368 > URL: https://issues.apache.org/jira/browse/JCR-3368 > Project: Jackrabbit Content Repository > Issue Type: Bug > Affects Versions: 2.2.12, 2.4.2, 2.5 > Reporter: Unico Hommes > Attachments: HasNodeAfterRemoveTest.java > > > See attached test case. > You will see the following exception: > javax.jcr.RepositoryException: failed to retrieve state of intermediary node > at org.apache.jackrabbit.core.CachingHierarchyManager.resolvePath(CachingHierarchyManager.java:156) > at org.apache.jackrabbit.core.HierarchyManagerImpl.resolveNodePath(HierarchyManagerImpl.java:372) > at org.apache.jackrabbit.core.NodeImpl.getNodeId(NodeImpl.java:276) > at org.apache.jackrabbit.core.NodeImpl.resolveRelativeNodePath(NodeImpl.java:223) > at org.apache.jackrabbit.core.NodeImpl.hasNode(NodeImpl.java:2250) > at org.apache.jackrabbit.core.HasNodeAfterRemoveTest.testRemove(HasNodeAfterRemoveTest.java:14) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:616) > at junit.framework.TestCase.runTest(TestCase.java:168) > at junit.framework.TestCase.runBare(TestCase.java:134) > at junit.framework.TestResult$1.protect(TestResult.java:110) > at junit.framework.TestResult.runProtected(TestResult.java:128) > at junit.framework.TestResult.run(TestResult.java:113) > at junit.framework.TestCase.run(TestCase.java:124) > at org.apache.jackrabbit.test.AbstractJCRTest.run(AbstractJCRTest.java:456) > at junit.framework.TestSuite.runTest(TestSuite.java:243) > at junit.framework.TestSuite.run(TestSuite.java:238) > at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83) > at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62) > at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140) > at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127) > at org.apache.maven.surefire.Surefire.run(Surefire.java:177) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:616) > at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345) > at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009) > Caused by: org.apache.jackrabbit.core.state.NoSuchItemStateException: c7ccbcd3-0524-4d4d-a109-eae84627f94e > at org.apache.jackrabbit.core.state.SessionItemStateManager.getTransientItemState(SessionItemStateManager.java:304) > at org.apache.jackrabbit.core.state.SessionItemStateManager.getItemState(SessionItemStateManager.java:153) > at org.apache.jackrabbit.core.HierarchyManagerImpl.getItemState(HierarchyManagerImpl.java:152) > at org.apache.jackrabbit.core.HierarchyManagerImpl.resolvePath(HierarchyManagerImpl.java:115) > at org.apache.jackrabbit.core.CachingHierarchyManager.resolvePath(CachingHierarchyManager.java:152) > ... 29 more > I tried several things to fix this but didn't find a better solution than to just wrap the statement > NodeId id = resolveRelativeNodePath(relPath); > in a try catch RepositoryException and return false when that exception occurs. > In particular I tried changing the implementation to > Path path = resolveRelativePath(relPath).getNormalizedPath(); > return itemMgr.nodeExists(path); > However, the repository doesn't even start up with that. Aparently the code relies on the null check for id as well. > Anyone have a better solution? -- 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