Program: 89136
Project: 89136
Buggy source:
/** 
 * Creates a new recorded version
 * @param sourceTypeRef                 source type name
 * @param versionHistoryRef             version history reference
 * @param standardVersionProperties     standard version properties
 * @param versionProperties             version properties
 * @param versionNumber                 version number
 * @param nodeDetails                   policy scope
 * @return {@link NodeRef}              record version
 */
protected NodeRef createNewRecordedVersion(QName sourceTypeRef,NodeRef versionHistoryRef,Map<QName,Serializable> standardVersionProperties,Map<String,Serializable> versionProperties,int versionNumber,PolicyScope nodeDetails){
  NodeRef versionNodeRef=null;
  policyBehaviourFilter.disableBehaviour(ContentModel.ASPECT_VERSIONABLE);
  policyBehaviourFilter.disableBehaviour(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT);
  policyBehaviourFilter.disableBehaviour(ContentModel.TYPE_MULTILINGUAL_CONTAINER);
  try {
    final NodeRef filePlan=(NodeRef)versionProperties.get(KEY_FILE_PLAN);
    if (filePlan == null) {
      throw new AlfrescoRuntimeException("String_Node_Str");
    }
    final NodeRef nodeRef=(NodeRef)standardVersionProperties.get(Version2Model.PROP_QNAME_FROZEN_NODE_REF);
    final NodeRef record=createRecord(nodeRef,filePlan);
    PropertyMap versionRecordProps=new PropertyMap(3);
    versionRecordProps.put(PROP_VERSIONED_NODEREF,nodeRef);
    versionRecordProps.put(RecordableVersionModel.PROP_VERSION_LABEL,standardVersionProperties.get(QName.createQName(Version2Model.NAMESPACE_URI,Version2Model.PROP_VERSION_LABEL)));
    versionRecordProps.put(RecordableVersionModel.PROP_VERSION_DESCRIPTION,standardVersionProperties.get(QName.createQName(Version2Model.NAMESPACE_URI,Version2Model.PROP_VERSION_DESCRIPTION)));
    nodeService.addAspect(record,ASPECT_VERSION_RECORD,versionRecordProps);
    VersionHistory versionHistory=getVersionHistory(nodeRef);
    if (versionHistory != null) {
      Collection<Version> previousVersions=versionHistory.getAllVersions();
      for (      Version previousVersion : previousVersions) {
        final NodeRef previousRecord=(NodeRef)previousVersion.getVersionProperties().get(PROP_VERSION_RECORD);
        if (previousRecord != null) {
          authenticationUtil.runAsSystem(new RunAsWork<Void>(){
            @Override public Void doWork() throws Exception {
              relationshipService.addRelationship("String_Node_Str",record,previousRecord);
              return null;
            }
          }
);
          break;
        }
      }
    }
    ChildAssociationRef childAssocRef=dbNodeService.createNode(versionHistoryRef,Version2Model.CHILD_QNAME_VERSIONS,QName.createQName(Version2Model.NAMESPACE_URI,Version2Model.CHILD_VERSIONS + "String_Node_Str" + versionNumber),sourceTypeRef,null);
    versionNodeRef=childAssocRef.getChildRef();
    nodeService.addAspect(versionNodeRef,Version2Model.ASPECT_VERSION,standardVersionProperties);
    nodeService.addAspect(versionNodeRef,ASPECT_RECORDED_VERSION,Collections.singletonMap(PROP_RECORD_NODE_REF,(Serializable)record));
    freezeAuditableAspect(nodeRef,versionNodeRef);
  }
  finally {
    this.policyBehaviourFilter.enableBehaviour(ContentModel.ASPECT_VERSIONABLE);
    this.policyBehaviourFilter.enableBehaviour(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT);
    this.policyBehaviourFilter.enableBehaviour(ContentModel.TYPE_MULTILINGUAL_CONTAINER);
  }
  if (dbNodeService.hasAspect(versionNodeRef,ContentModel.ASPECT_AUDITABLE) == false) {
    dbNodeService.addAspect(versionNodeRef,ContentModel.ASPECT_AUDITABLE,null);
  }
  if (logger.isTraceEnabled()) {
    logger.trace("String_Node_Str" + versionNumber + "String_Node_Str"+ versionNodeRef);
  }
  return versionNodeRef;
}

Fixed version (ground truth):
/** 
 * Creates a new recorded version
 * @param sourceTypeRef                 source type name
 * @param versionHistoryRef             version history reference
 * @param standardVersionProperties     standard version properties
 * @param versionProperties             version properties
 * @param versionNumber                 version number
 * @param nodeDetails                   policy scope
 * @return {@link NodeRef}              record version
 */
protected NodeRef createNewRecordedVersion(QName sourceTypeRef,NodeRef versionHistoryRef,Map<QName,Serializable> standardVersionProperties,Map<String,Serializable> versionProperties,int versionNumber,PolicyScope nodeDetails){
  NodeRef versionNodeRef=null;
  policyBehaviourFilter.disableBehaviour(ContentModel.ASPECT_VERSIONABLE);
  policyBehaviourFilter.disableBehaviour(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT);
  policyBehaviourFilter.disableBehaviour(ContentModel.TYPE_MULTILINGUAL_CONTAINER);
  try {
    final NodeRef filePlan=(NodeRef)versionProperties.get(KEY_FILE_PLAN);
    if (filePlan == null) {
      throw new AlfrescoRuntimeException("String_Node_Str");
    }
    final NodeRef nodeRef=(NodeRef)standardVersionProperties.get(Version2Model.PROP_QNAME_FROZEN_NODE_REF);
    final NodeRef record=createRecord(nodeRef,filePlan);
    PropertyMap versionRecordProps=new PropertyMap(3);
    versionRecordProps.put(PROP_VERSIONED_NODEREF,nodeRef);
    versionRecordProps.put(RecordableVersionModel.PROP_VERSION_LABEL,standardVersionProperties.get(QName.createQName(Version2Model.NAMESPACE_URI,Version2Model.PROP_VERSION_LABEL)));
    versionRecordProps.put(RecordableVersionModel.PROP_VERSION_DESCRIPTION,standardVersionProperties.get(QName.createQName(Version2Model.NAMESPACE_URI,Version2Model.PROP_VERSION_DESCRIPTION)));
    nodeService.addAspect(record,ASPECT_VERSION_RECORD,versionRecordProps);
    VersionHistory versionHistory=getVersionHistory(nodeRef);
    if (versionHistory != null) {
      Collection<Version> previousVersions=versionHistory.getAllVersions();
      for (      Version previousVersion : previousVersions) {
        final NodeRef previousRecord=(NodeRef)previousVersion.getVersionProperties().get(PROP_VERSION_RECORD);
        if (previousRecord != null) {
          authenticationUtil.runAsSystem(new RunAsWork<Void>(){
            @Override public Void doWork() throws Exception {
              relationshipService.addRelationship("String_Node_Str",record,previousRecord);
              return null;
            }
          }
);
          break;
        }
      }
    }
    ChildAssociationRef childAssocRef=dbNodeService.createNode(versionHistoryRef,Version2Model.CHILD_QNAME_VERSIONS,QName.createQName(Version2Model.NAMESPACE_URI,Version2Model.CHILD_VERSIONS + "String_Node_Str" + versionNumber),sourceTypeRef,null);
    versionNodeRef=childAssocRef.getChildRef();
    nodeService.addAspect(versionNodeRef,Version2Model.ASPECT_VERSION,standardVersionProperties);
    nodeService.addAspect(versionNodeRef,ASPECT_RECORDED_VERSION,Collections.singletonMap(PROP_RECORD_NODE_REF,(Serializable)record));
    freezeAuditableAspect(nodeRef,versionNodeRef);
  }
  finally {
    this.policyBehaviourFilter.enableBehaviour(ContentModel.ASPECT_VERSIONABLE);
    this.policyBehaviourFilter.enableBehaviour(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT);
    this.policyBehaviourFilter.enableBehaviour(ContentModel.TYPE_MULTILINGUAL_CONTAINER);
  }
  if (!dbNodeService.hasAspect(versionNodeRef,ContentModel.ASPECT_AUDITABLE)) {
    dbNodeService.addAspect(versionNodeRef,ContentModel.ASPECT_AUDITABLE,null);
  }
  if (logger.isTraceEnabled()) {
    logger.trace("String_Node_Str" + versionNumber + "String_Node_Str"+ versionNodeRef);
  }
  return versionNodeRef;
}