[
https://issues.apache.org/jira/browse/OAK-11187?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Joerg Hoh closed OAK-11187.
---------------------------
> Implement NodeImpl.getParentOrNull
> ----------------------------------
>
> Key: OAK-11187
> URL: https://issues.apache.org/jira/browse/OAK-11187
> Project: Jackrabbit Oak
> Issue Type: Improvement
> Components: core, jackrabbit-api
> Reporter: Joerg Hoh
> Assignee: Joerg Hoh
> Priority: Major
> Fix For: 1.72.0
>
>
> The JackrabbitSession already has an default implementation of
> {noformat}
> default Node getParentOrNull(@NotNull Item item) throws RepositoryException
> {noformat}
> but internally there is no optimized version available. This can be useful,
> as I have seen cases in threaddumps, where the Node.getParent()
> implementation creates an AccessDeniedException; so there is definitely some
> value in an implementation of {{getParentOrNull}} in the JR extensions which
> avoids the creation of such an exception.
> I have here a series of threaddumps, and of the 35 instances of
> {{JackrabbitSesion.getParentOrNull()}} 22 look like this:
> {noformat}
> at java.lang.Throwable.fillInStackTrace([email protected]/Native
> Method)
> at
> java.lang.Throwable.fillInStackTrace([email protected]/Throwable.java:787)
> - locked <0x00000007300d7860> (a javax.jcr.AccessDeniedException)
> at java.lang.Throwable.<init>([email protected]/Throwable.java:255)
> at java.lang.Exception.<init>([email protected]/Exception.java:54)
> at javax.jcr.RepositoryException.<init>(RepositoryException.java:17)
> at
> javax.jcr.security.AccessControlException.<init>(AccessControlException.java:21)
> at
> javax.jcr.AccessDeniedException.<init>(AccessDeniedException.java:17)
> at
> org.apache.jackrabbit.oak.jcr.session.NodeImpl$1.perform(NodeImpl.java:195)
> at
> org.apache.jackrabbit.oak.jcr.session.NodeImpl$1.perform(NodeImpl.java:186)
> at
> org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:229)
> at
> org.apache.jackrabbit.oak.jcr.session.ItemImpl.perform(ItemImpl.java:113)
> at
> org.apache.jackrabbit.oak.jcr.session.NodeImpl.getParent(NodeImpl.java:186)
> at
> org.apache.jackrabbit.api.JackrabbitSession.getParentOrNull(JackrabbitSession.java:272)
> at
> org.apache.sling.jcr.resource.internal.helper.jcr.JcrItemResourceFactory.getParentOrNull(JcrItemResourceFactory.java:218)
> {noformat}
> For that reason I think that in the cases where {{getParent()}} either hits
> the root node or a non-accessible parent node, the performance penalty of the
> exception is quite high.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)