OAK-10335 TypeEditor misapplies default primary type of child node to its parent when the child primary type is not set
@adamcin , please don't add unrelated changes to this PR like changing variable names. it makes it hard to identify the effective changes you are making.
as far as the effective changes are concerned: i would need to take a closer look at the TypeEditor and it's usages. in general 'childNodeChanged' receives the nodestate of the modified node as 'childNodeAdded' receives the newly added child node. i don't recall exactly what the nature of the 'builder' is.... and if retrieving the child is equivalent to the state that is passed.
anyway: as far as i can see the relevant change is actually only on line 299, where the primary type gets set on the child-builder (which is then already available for the 'validate the child node'). so the PR should only change that and avoid any unrelated changes. i can then take a look again in the ide to get a better sense of then change.
Thanks, @anchela . I'll restore the original variable names.
The after NodeState appears to represent the child node state in both the childNodeChanged and childNodeAdded methods, at least according to the Editor interface [1], as well the TypeEditor implementation of childNodeAdded [2], which delegates to childNodeChanged by passing the after parameter without modifying it.
[1] https://github.com/apache/jackrabbit-oak/blob/03b703e91f9964a2f192ccd34526d5980561839a/oak-store-spi/src/main/java/org/apache/jackrabbit/oak/spi/commit/Editor.java#L93-L120 [2] https://github.com/apache/jackrabbit-oak/blob/03b703e91f9964a2f192ccd34526d5980561839a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditor.java#L281-L286