Program: 172305
Project: 172305
Buggy source:
/** 
 * Copies the child associations onto the destiantion node reference. <p> If copyChildren is true then the nodes at the end of a primary assoc will be copied before they are associated.
 * @param classRef				the class reference
 * @param destinationNodeRef	the destination node reference
 * @param copyDetails			the copy details
 * @param copyChildren			indicates whether to copy the primary children
 */
private void copyChildAssociations(QName classRef,NodeRef destinationNodeRef,PolicyScope copyDetails,boolean copyChildren,Map<NodeRef,NodeRef> copiedChildren){
  List<ChildAssociationRef> childAssocs=copyDetails.getChildAssociations(classRef);
  if (childAssocs != null) {
    for (    ChildAssociationRef childAssoc : childAssocs) {
      if (copyChildren == true) {
        if (childAssoc.isPrimary() == true) {
          if (copiedChildren.containsKey(childAssoc.getChildRef()) == false && copiedChildren.containsValue(childAssoc.getChildRef()) == false) {
            recursiveCopy(childAssoc.getChildRef(),destinationNodeRef,childAssoc.getTypeQName(),childAssoc.getQName(),copyChildren,copiedChildren);
          }
        }
 else {
          NodeRef childRef=childAssoc.getChildRef();
          this.nodeService.addChild(destinationNodeRef,childRef,childAssoc.getTypeQName(),childAssoc.getQName());
        }
      }
 else {
        NodeRef childRef=childAssoc.getChildRef();
        QName childType=this.nodeService.getType(childRef);
        if (this.dictionaryService.isSubClass(childType,ContentModel.TYPE_CONFIGURATIONS) == true || copyDetails.isChildAssociationRefAlwaysTraversed(classRef,childAssoc) == true) {
          if (copiedChildren.containsKey(childRef) == false) {
            recursiveCopy(childRef,destinationNodeRef,childAssoc.getTypeQName(),childAssoc.getQName(),true,copiedChildren);
          }
        }
 else {
          this.nodeService.addChild(destinationNodeRef,childRef,childAssoc.getTypeQName(),childAssoc.getQName());
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Copies the child associations onto the destiantion node reference. <p> If copyChildren is true then the nodes at the end of a primary assoc will be copied before they are associated.
 * @param classRef				the class reference
 * @param destinationNodeRef	the destination node reference
 * @param copyDetails			the copy details
 * @param copyChildren			indicates whether to copy the primary children
 */
private void copyChildAssociations(QName classRef,NodeRef destinationNodeRef,PolicyScope copyDetails,boolean copyChildren,Map<NodeRef,NodeRef> copiedChildren){
  List<ChildAssociationRef> childAssocs=copyDetails.getChildAssociations(classRef);
  if (childAssocs != null) {
    for (    ChildAssociationRef childAssoc : childAssocs) {
      if (copyChildren == true) {
        if (childAssoc.isPrimary() == true) {
          if (copiedChildren.containsKey(childAssoc.getChildRef()) == false && copiedChildren.containsValue(childAssoc.getChildRef()) == false) {
            recursiveCopy(childAssoc.getChildRef(),childAssoc.getParentRef(),destinationNodeRef,childAssoc.getTypeQName(),childAssoc.getQName(),copyChildren,false,copiedChildren);
          }
        }
 else {
          NodeRef childRef=childAssoc.getChildRef();
          this.nodeService.addChild(destinationNodeRef,childRef,childAssoc.getTypeQName(),childAssoc.getQName());
        }
      }
 else {
        NodeRef childRef=childAssoc.getChildRef();
        QName childType=this.nodeService.getType(childRef);
        if (this.dictionaryService.isSubClass(childType,ContentModel.TYPE_CONFIGURATIONS) == true || copyDetails.isChildAssociationRefAlwaysTraversed(classRef,childAssoc) == true) {
          if (copiedChildren.containsKey(childRef) == false) {
            recursiveCopy(childRef,childAssoc.getParentRef(),destinationNodeRef,childAssoc.getTypeQName(),childAssoc.getQName(),true,false,copiedChildren);
          }
        }
 else {
          this.nodeService.addChild(destinationNodeRef,childRef,childAssoc.getTypeQName(),childAssoc.getQName());
        }
      }
    }
  }
}