Program: 139707
Project: 139707
Buggy source:
private static String createAndStorePattern(PatternParameters parameters,IFolder selectionFolder,ExpressionType type){
  Pattern pattern=PatternResourceFileHelper.getInstance().createPattern(parameters.name,parameters.auther,parameters.description,parameters.purpose,parameters.status);
  for (  String key : parameters.regex.keySet()) {
    RegularExpression regularExpr=BooleanExpressionHelper.createRegularExpression(key,parameters.regex.get(key),type);
    pattern.getComponents().add(regularExpr);
  }
  boolean validStatus=PatternUtilities.isPatternValid(pattern);
  TaggedValueHelper.setValidStatus(validStatus,pattern);
  String fname=DqRepositoryViewService.createFilename(parameters.name,NewSourcePatternActionProvider.EXTENSION_PATTERN);
  try {
    String[] folderNames=parameters.relativePath.split("String_Node_Str");
    if (1 == folderNames.length && "String_Node_Str".equals(folderNames[0])) {
switch (type) {
case SQL_LIKE:
        folderNames[0]=DQStructureManager.SQL;
      break;
case REGEXP:
    folderNames[0]=DQStructureManager.REGEX;
  break;
}
}
for (String folderName : folderNames) {
IFolder folder=selectionFolder.getFolder(folderName);
if (!folder.exists()) {
folder.create(false,true,null);
}
folder.setPersistentProperty(DQStructureManager.FOLDER_CLASSIFY_KEY,DQStructureManager.PATTERNS_FOLDER_PROPERTY);
selectionFolder=folder;
}
}
 catch (CoreException e) {
log.error(e,e);
}
IFile pfile=selectionFolder.getFile(fname);
EMFSharedResources.getInstance().addEObjectToResourceSet(pfile.getFullPath().toString(),pattern);
EMFSharedResources.getInstance().saveLastResource();
return selectionFolder.getName();
}

Fixed version (ground truth):
private static String createAndStorePattern(PatternParameters parameters,IFolder selectionFolder,ExpressionType type){
  Pattern pattern=PatternResourceFileHelper.getInstance().createPattern(parameters.name,parameters.auther,parameters.description,parameters.purpose,parameters.status);
  for (  String key : parameters.regex.keySet()) {
    RegularExpression regularExpr=BooleanExpressionHelper.createRegularExpression(key,parameters.regex.get(key),type);
    pattern.getComponents().add(regularExpr);
  }
  boolean validStatus=PatternUtilities.isPatternValid(pattern);
  TaggedValueHelper.setValidStatus(validStatus,pattern);
  String fname=DqRepositoryViewService.createFilename(parameters.name,NewSourcePatternActionProvider.EXTENSION_PATTERN);
  try {
    String[] folderNames=parameters.relativePath.split("String_Node_Str");
    for (    String folderName : folderNames) {
      IFolder folder=selectionFolder.getFolder(folderName);
      if (!folder.exists()) {
        folder.create(false,true,null);
      }
      folder.setPersistentProperty(DQStructureManager.FOLDER_CLASSIFY_KEY,DQStructureManager.PATTERNS_FOLDER_PROPERTY);
      selectionFolder=folder;
    }
  }
 catch (  CoreException e) {
    log.error(e,e);
  }
  IFile pfile=selectionFolder.getFile(fname);
  EMFSharedResources.getInstance().addEObjectToResourceSet(pfile.getFullPath().toString(),pattern);
  EMFSharedResources.getInstance().saveLastResource();
  return ResourceManager.getLibrariesFolder().getFolder(DQStructureManager.PATTERNS).getLocationURI().relativize(selectionFolder.getLocationURI()).toString();
}