[
https://issues.apache.org/jira/browse/OAK-635?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13581138#comment-13581138
]
Alex Parvulescu commented on OAK-635:
-------------------------------------
It appears that the cause is PrivilegeDefinitionStore#getBits calls
privilegesTree.getChild(privilegeName) with a null value.
Going through the code, there is no real null child name protection [0].
So we potentially have 2 layers where the null check is missing
- trees Tree#getChild (all impls)
- node states NodeState#getChildNode (all impls)
There are also the NodeBuilders but those are more wrapper types and delegate
to NodeStates, so I'm not sure if that code should be checked.
[0]The only reason the KernelNodeState doesn't have the NPE is the way the
childPaths map works:
{noformat}
String childPath = childPaths.get(name);
if (childPath == null && childNodeCount > MAX_CHILD_NODE_NAMES) {
{noformat}
... in this particular case, the name is null, so the #get call returns null,
skips the _if_ and returns null directly - not really a null check in itself.
> SegmentMK NPE in SegmentNodeState#getChildNode
> ----------------------------------------------
>
> Key: OAK-635
> URL: https://issues.apache.org/jira/browse/OAK-635
> Project: Jackrabbit Oak
> Issue Type: Sub-task
> Components: segmentmk
> Reporter: Alex Parvulescu
>
> There are 2 tests failing in oak-core because of a NPE at
> SegmentNodeState.getChildNode(SegmentNodeState.java:87):
> -
> testSetPolicy(org.apache.jackrabbit.oak.security.authorization.AccessControlManagerImplTest)
> -
> testSetPolicyWritesAcContent(org.apache.jackrabbit.oak.security.authorization.AccessControlManagerImplTest)
> {noformat}
> java.lang.NullPointerException
> at
> com.google.common.base.Preconditions.checkNotNull(Preconditions.java:191)
> at
> org.apache.jackrabbit.oak.plugins.segment.SegmentNodeState.getChildNode(SegmentNodeState.java:87)
> at
> org.apache.jackrabbit.oak.core.ReadOnlyTree.getChild(ReadOnlyTree.java:140)
> at
> org.apache.jackrabbit.oak.core.ReadOnlyTree.getChild(ReadOnlyTree.java:1)
> at
> org.apache.jackrabbit.oak.security.privilege.PrivilegeDefinitionStore.getBits(PrivilegeDefinitionStore.java:113)
> at
> org.apache.jackrabbit.oak.security.authorization.PermissionHook$Diff.createEntry(PermissionHook.java:246)
> at
> org.apache.jackrabbit.oak.security.authorization.PermissionHook$Diff.addEntry(PermissionHook.java:206)
> at
> org.apache.jackrabbit.oak.security.authorization.PermissionHook$Diff.childNodeAdded(PermissionHook.java:148)
> at
> org.apache.jackrabbit.oak.spi.state.AbstractNodeState.compareAgainstBaseState(AbstractNodeState.java:157)
> at
> org.apache.jackrabbit.oak.security.authorization.PermissionHook$Diff.childNodeAdded(PermissionHook.java:152)
> at
> org.apache.jackrabbit.oak.spi.state.AbstractNodeState.compareAgainstBaseState(AbstractNodeState.java:157)
> at
> org.apache.jackrabbit.oak.security.authorization.PermissionHook$Diff.childNodeChanged(PermissionHook.java:165)
> at
> org.apache.jackrabbit.oak.plugins.memory.ModifiedNodeState$3.childNodeChanged(ModifiedNodeState.java:298)
> at
> org.apache.jackrabbit.oak.spi.state.AbstractNodeState.compareAgainstBaseState(AbstractNodeState.java:150)
> at
> org.apache.jackrabbit.oak.plugins.memory.ModifiedNodeState.compareAgainstBaseState(ModifiedNodeState.java:269)
> at
> org.apache.jackrabbit.oak.security.authorization.PermissionHook.processCommit(PermissionHook.java:76)
> at
> org.apache.jackrabbit.oak.spi.commit.CompositeHook.processCommit(CompositeHook.java:59)
> at
> org.apache.jackrabbit.oak.spi.commit.CompositeHook.processCommit(CompositeHook.java:59)
> at
> org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStoreBranch.merge(SegmentNodeStoreBranch.java:179)
> at org.apache.jackrabbit.oak.core.RootImpl$2.run(RootImpl.java:257)
> at org.apache.jackrabbit.oak.core.RootImpl$2.run(RootImpl.java:1)
> at java.security.AccessController.doPrivileged(Native Method)
> at javax.security.auth.Subject.doAs(Subject.java:337)
> at org.apache.jackrabbit.oak.core.RootImpl.commit(RootImpl.java:252)
> at
> org.apache.jackrabbit.oak.security.authorization.AccessControlManagerImplTest.testSetPolicyWritesAcContent(AccessControlManagerImplTest.java:585){noformat}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira