You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current implementation of MoveStrategy.MERGE uses ConfigurationNode#mergeFrom(ConfigurationNode) to merge nodes that have their path changed in a TransformAction. The problem with this implementation is in this line from SingleConfigurationTransformation:
If the transformedPath does not exist within the node structure, then a virtual node is returned. When this virtual node is passed through MoveStrategy.OVERWRITE, it is run through ConfigurationNode#from(ConfigurationNode). This method properly attaches the node if necessary to its parent and then overwrites the node. However, MoveStrategy.MERGE and therefore ConfigurationNode#mergeFrom(ConfigurationNode), does not actually attempt to attach the node if necessary back to its parent on merge. This causes the merged node to never actually update in the structure of the start node, and therefore breaks if trying to use MoveStrategy.MERGE when the target node is virtual. This seems like unintended behavior.
Consider the following situation: A developer might want to use MoveStrategy.MERGE for their transformation builder because they want to move and merge one node. However, they might also want to move a separate node to a new target path even if that path doesn't exist (e.g. oldlocation to newlocation). Yet, with MoveStrategy.MERGE in use, the target node (newlocation) doesn't exist and is virtual, and oldlocation is merged into newlocation. This newlocation virtual node is never actually attached back to the parent. Being required to use MoveStrategy.OVERWRITE to be able to move old nodes to new, non-existent locations seems like an oversight in the library.
The text was updated successfully, but these errors were encountered:
SizableShrimp
changed the title
MoveStrategy.MERGE does not work if the moved node does not exist
MoveStrategy.MERGE does not work if the target node does not exist
Nov 6, 2020
The current implementation of
MoveStrategy.MERGE
usesConfigurationNode#mergeFrom(ConfigurationNode)
to merge nodes that have their path changed in aTransformAction
. The problem with this implementation is in this line fromSingleConfigurationTransformation
:If the
transformedPath
does not exist within the node structure, then a virtual node is returned. When this virtual node is passed throughMoveStrategy.OVERWRITE
, it is run throughConfigurationNode#from(ConfigurationNode)
. This method properly attaches the node if necessary to its parent and then overwrites the node. However,MoveStrategy.MERGE
and thereforeConfigurationNode#mergeFrom(ConfigurationNode)
, does not actually attempt to attach the node if necessary back to its parent on merge. This causes the merged node to never actually update in the structure of thestart
node, and therefore breaks if trying to useMoveStrategy.MERGE
when the target node is virtual. This seems like unintended behavior.Consider the following situation: A developer might want to use
MoveStrategy.MERGE
for their transformation builder because they want to move and merge one node. However, they might also want to move a separate node to a new target path even if that path doesn't exist (e.g.oldlocation
tonewlocation
). Yet, withMoveStrategy.MERGE
in use, the target node (newlocation
) doesn't exist and is virtual, andoldlocation
is merged intonewlocation
. Thisnewlocation
virtual node is never actually attached back to the parent. Being required to useMoveStrategy.OVERWRITE
to be able to move old nodes to new, non-existent locations seems like an oversight in the library.The text was updated successfully, but these errors were encountered: