Program: 137789
Project: 137789
Buggy source:
private static String createAndStorePattern(PatternParameters parameters,IFolder selectionFolder,ExpressionType type) throws TalendInternalPersistenceException {
  Pattern pattern=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);
      }
      selectionFolder=folder;
    }
  }
 catch (  CoreException e) {
    log.error(e,e);
  }
  IFile pfile=selectionFolder.getFile(fname);
  TypedReturnCode<Object> create=ElementWriterFactory.getInstance().createPatternWriter().create(pattern,selectionFolder);
  if (create.isOk()) {
    return ResourceManager.getPatternFolder().getLocationURI().relativize(selectionFolder.getLocationURI()).toString();
  }
 else {
    throw new TalendInternalPersistenceException(create.getMessage());
  }
}

Fixed version (ground truth):
private static String createAndStorePattern(PatternParameters parameters,IFolder selectionFolder,ExpressionType type) throws TalendInternalPersistenceException {
  Pattern pattern=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 relativePath=parameters.relativePath;
    if (EResourceConstant.PATTERN_REGEX.getName().equals(relativePath) || EResourceConstant.PATTERN_SQL.getName().equals(relativePath)) {
      relativePath=PluginConstant.EMPTY_STRING;
    }
    String[] folderNames=relativePath.split("String_Node_Str");
    for (    String folderName : folderNames) {
      IFolder folder=selectionFolder.getFolder(folderName);
      if (!folder.exists()) {
        folder.create(false,true,null);
      }
      selectionFolder=folder;
    }
  }
 catch (  CoreException e) {
    log.error(e,e);
  }
  IFile pfile=selectionFolder.getFile(fname);
  TypedReturnCode<Object> create=ElementWriterFactory.getInstance().createPatternWriter().create(pattern,selectionFolder);
  if (create.isOk()) {
    return ResourceManager.getPatternFolder().getLocationURI().relativize(selectionFolder.getLocationURI()).toString();
  }
 else {
    throw new TalendInternalPersistenceException(create.getMessage());
  }
}