[
https://issues.apache.org/jira/browse/OAK-11811?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Manfred Baedke reassigned OAK-11811:
------------------------------------
Assignee: Manfred Baedke
> Resolve questionable recursion in NodeTypeImpl
> ----------------------------------------------
>
> Key: OAK-11811
> URL: https://issues.apache.org/jira/browse/OAK-11811
> Project: Jackrabbit Oak
> Issue Type: Task
> Components: core
> Affects Versions: 1.80.0
> Reporter: Joerg Hoh
> Assignee: Manfred Baedke
> Priority: Major
>
> NodeTypeImpl.internalIsNodeType does a recursive call to itself, but it
> re-uses the same parameter {{oakName}} which it is getting passed. That means
> it either returns early or runs into an endless recursion.
> [Github|https://github.com/apache/jackrabbit-oak/blob/06b7ff2278cdfe432c2ed7cfcdb17f195fca9722/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/NodeTypeImpl.java#L494-L504]
> {noformat}
> boolean internalIsNodeType(String oakName) {
> if (getOakName().equals(oakName)) {
> return true;
> }
> for (NodeType type : getDeclaredSupertypes()) {
> if (((NodeTypeImpl) type).internalIsNodeType(oakName)) {
> return true;
> }
> }
> return false;
> }
> {noformat}
> A quick test shows, that with this diff applied it also passes all unittests:
> {noformat}
> @@ -496,7 +496,7 @@ class NodeTypeImpl extends AbstractTypeDefinition
> implements NodeType {
> return true;
> }
> for (NodeType type : getDeclaredSupertypes()) {
> - if (((NodeTypeImpl) type).internalIsNodeType(oakName)) {
> + if (((NodeTypeImpl) type).getOakName().equals(oakName)) {
> return true;
> }
> }
> {noformat}
> Is this is the correct and intended behavior? I am not entirely sure about
> this, as it would mean that {{getDeclaredSupertypes()}} would need to return
> all transitive supertypes as well, and I don't see that in the code.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)