Uploaded image for project: 'Jackrabbit Oak'
  1. Jackrabbit Oak
  2. OAK-11187

Implement NodeImpl.getParentOrNull

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.72.0
    • core, jackrabbit-api
    • None

    Description

      The JackrabbitSession already has an default implementation of

      default Node getParentOrNull(@NotNull Item item) throws RepositoryException 
      

      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:

              at java.lang.Throwable.fillInStackTrace(java.base@11.0.23/Native Method)
              at java.lang.Throwable.fillInStackTrace(java.base@11.0.23/Throwable.java:787)
              - locked <0x00000007300d7860> (a javax.jcr.AccessDeniedException)
              at java.lang.Throwable.<init>(java.base@11.0.23/Throwable.java:255)
              at java.lang.Exception.<init>(java.base@11.0.23/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)
      

      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.

      Attachments

        Issue Links

          Activity

            People

              joerghoh Joerg Hoh
              joerghoh Joerg Hoh
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: