nus-yam/ex-repair huggingface dataset:
Program: 39627
Project: 39627
Buggy source:
/** 
 * Sets the relative path from the application root folder to the file or folder the transformation utility should perform against. The path separator is automatically normalized, so there are three valid options when separating folders in the path: <ol> <li>File.separatorChar (e.g. relative("myFolder" + File.separator + "file.txt")</li> <li>Forward slash (e.g. relative("myFolder/file.txt")</li> <li>Two backward slashes (e.g. relative("myFolder\\file.txt")</li> </ol> The slashes are replaced by OS specific separator char in runtime. <br> <strong>The default value is ".". which means the root of the transformed application </strong>
 * @param relativePath from the application root folderto the file or folder the transformation utility should be performed against
 * @return this transformation utility
 */
public final TU relative(String relativePath){
  this.relativePath=normalizeRelativePathSeparator(relativePath);
  return (TU)this;
}

Fixed version (ground truth):
/** 
 * Sets the relative path from the application root folder to the file or folder the transformation utility should perform against. The path separator is automatically normalized, so there are three valid options when separating folders in the path: <ol> <li>File.separatorChar (e.g. relative("myFolder" + File.separator + "file.txt")</li> <li>Forward slash (e.g. relative("myFolder/file.txt")</li> <li>Two backward slashes (e.g. relative("myFolder\\file.txt")</li> </ol> The slashes are replaced by OS specific separator char in runtime. <br> <strong>The default value is ".". which means the root of the transformed application</strong>
 * @param relativePath from the application root folderto the file or folder the transformation utility should be performed against
 * @return this transformation utility
 */
public final TU relative(String relativePath){
  this.relativePath=normalizeRelativePathSeparator(relativePath);
  return (TU)this;
}
Program: 39628
Project: 39628
Buggy source:
/** 
 * Utility to find files based on a regular expression against the file name and/or the file path. The search might be recursive (including sub-folders) or not. If a file path regular expression is set, then the search will be automatically and necessarily recursive. If no file path regular expression is set, then the search is not recursive by default, but it may be set to as well. </br> The root directory from where the search should take place can be defined by   {@link #relative(String)},  {@link #absolute(String)} or {@link #absolute(String,String)}. If not set explicitly, then the search will happen from the root of the transformed application, which is equivalent to setting  {@link #relative(String)} to {@code "."}
 * @param nameRegex regular expression to be applied against file name during search
 * @param pathRegex regular expression to be applied against file path during search
 */
public FindFiles(String nameRegex,String pathRegex){
  setNameRegex(nameRegex);
  setPathRegex(pathRegex);
}

Fixed version (ground truth):
/** 
 * Utility to find files based on a regular expression against the file name and/or the file path. The search might be recursive (including sub-folders) or not. If a file path regular expression is set, then the search will be automatically and necessarily recursive. If no file path regular expression is set, then the search is not recursive by default, but it may be set to as well. <br> The root directory from where the search should take place can be defined by   {@link #relative(String)},  {@link #absolute(String)} or {@link #absolute(String,String)}. If not set explicitly, then the search will happen from the root of the transformed application, which is equivalent to setting  {@link #relative(String)} to {@code "."}
 * @param nameRegex regular expression to be applied against file name during search
 * @param pathRegex regular expression to be applied against file path during search
 */
public FindFiles(String nameRegex,String pathRegex){
  setNameRegex(nameRegex);
  setPathRegex(pathRegex);
}
Program: 39629
Project: 39629
Buggy source:
/** 
 * Set regular expression to be used to match the file path during the search</br> <strong>Important notes:</strong> <ul> <li>Use forward slash as file separator. If the OS used during transformation execution uses another character as file separator, that will be automatically converted by this utility</li> <li>Setting this to a non null value automatically sets recursive property to true</li> <li>This regular expression will be evaluated against the file path <strong>starting from the search root directory</strong></li> </ul>
 * @param pathRegex regular expression to be used to match the file pathduring the search
 * @return this transformation utility instance
 */
public FindFiles setPathRegex(String pathRegex){
  checkForEmptyString("String_Node_Str",pathRegex);
  this.pathRegex=pathRegex;
  if (pathRegex != null) {
    recursive=true;
  }
  return this;
}

Fixed version (ground truth):
/** 
 * Set regular expression to be used to match the file path during the search<br> <strong>Important notes:</strong> <ul> <li>Use forward slash as file separator. If the OS used during transformation execution uses another character as file separator, that will be automatically converted by this utility</li> <li>Setting this to a non null value automatically sets recursive property to true</li> <li>This regular expression will be evaluated against the file path <strong>starting from the search root directory</strong></li> </ul>
 * @param pathRegex regular expression to be used to match the file pathduring the search
 * @return this transformation utility instance
 */
public FindFiles setPathRegex(String pathRegex){
  checkForEmptyString("String_Node_Str",pathRegex);
  this.pathRegex=pathRegex;
  if (pathRegex != null) {
    recursive=true;
  }
  return this;
}
Program: 39630
Project: 39630
Buggy source:
/** 
 * Set whether the search should be recursive or not. If a file path regular expression has been set, then this property will be automatically set to true.</br> <strong>Important: setting this to false automatically sets the file path regular expression to null</strong>
 * @param recursive whether the search should be recursive
 * @return this transformation utility instance
 */
public FindFiles setRecursive(boolean recursive){
  this.recursive=recursive;
  if (!recursive) {
    pathRegex=null;
  }
  return this;
}

Fixed version (ground truth):
/** 
 * Set whether the search should be recursive or not. If a file path regular expression has been set, then this property will be automatically set to true.<br> <strong>Important: setting this to false automatically sets the file path regular expression to null</strong>
 * @param recursive whether the search should be recursive
 * @return this transformation utility instance
 */
public FindFiles setRecursive(boolean recursive){
  this.recursive=recursive;
  if (!recursive) {
    pathRegex=null;
  }
  return this;
}
Program: 39631
Project: 39631
Buggy source:
/** 
 * This is a tree of Maven artifacts, which are represented by   {@link Model} objects.The idea here is, given a list of Maven pom.xml  {@link File} objects, create a treebased on dependency among them, but specifying explicitly which Maven artifact should be at the root of the tree. That means, if any artifact in the list is not a child, directly or indirectly, of the root artifact, then it will end up no being in the tree. </br> As a result of building this tree, it is possible to know, out of the initial pom.xml files list, which ones actually inherit, directly or not, from the root artifact. The result is retrieved by calling  {@link #getPomFilesInTree()}
 * @param rootGroupId the group id of the artifact that should be at the root of the tree
 * @param rootArtifactId the artifact id of the artifact that should be at the root of the tree
 * @param rootVersion the version of the artifact that should be at the root of the tree
 * @param pomFiles a list of pom.xml files used to make the tree
 */
public ModelTree(String rootGroupId,String rootArtifactId,String rootVersion,List<File> pomFiles){
  Model rootModel=new Model();
  rootModel.setGroupId(rootGroupId);
  rootModel.setArtifactId(rootArtifactId);
  rootModel.setVersion(rootVersion);
  List<Model> models=new ArrayList<>();
  models.add(rootModel);
  for (  File pomFile : pomFiles) {
    models.add(createModel(pomFile));
  }
  add(models);
}

Fixed version (ground truth):
/** 
 * This is a tree of Maven artifacts, which are represented by   {@link Model} objects.The idea here is, given a list of Maven pom.xml  {@link File} objects, create a treebased on dependency among them, but specifying explicitly which Maven artifact should be at the root of the tree. That means, if any artifact in the list is not a child, directly or indirectly, of the root artifact, then it will end up no being in the tree. <br> As a result of building this tree, it is possible to know, out of the initial pom.xml files list, which ones actually inherit, directly or not, from the root artifact. The result is retrieved by calling  {@link #getPomFilesInTree()}
 * @param rootGroupId the group id of the artifact that should be at the root of the tree
 * @param rootArtifactId the artifact id of the artifact that should be at the root of the tree
 * @param rootVersion the version of the artifact that should be at the root of the tree
 * @param pomFiles a list of pom.xml files used to make the tree
 */
public ModelTree(String rootGroupId,String rootArtifactId,String rootVersion,List<File> pomFiles){
  Model rootModel=new Model();
  rootModel.setGroupId(rootGroupId);
  rootModel.setArtifactId(rootArtifactId);
  rootModel.setVersion(rootVersion);
  List<Model> models=new ArrayList<>();
  models.add(rootModel);
  for (  File pomFile : pomFiles) {
    models.add(createModel(pomFile));
  }
  add(models);
}
Program: 39632
Project: 39632
Buggy source:
/** 
 * @see {@link Reader#close()}
 * @throws IOException
 */
public void close() throws IOException {
  reader.close();
}

Fixed version (ground truth):
/** 
 * See   {@link Reader#close()}.
 * @throws IOException
 */
public void close() throws IOException {
  reader.close();
}
Program: 39633
Project: 39633
Buggy source:
public void setInputArguments(String[] inputArguments){
  this.inputArguments=inputArguments;
}

Fixed version (ground truth):
public void setInputArguments(String[] inputArguments){
  this.inputArguments=Arrays.copyOf(inputArguments,inputArguments.length);
}
Program: 39634
Project: 39634
Buggy source:
public AbstractTypeCheck(String specifiedTypeName){
  if (specifiedTypeName == null && specifiedTypeName.trim().length() == 0) {
    throw new TransformationDefinitionException("String_Node_Str");
  }
  this.specifiedTypeName=specifiedTypeName;
  int i=specifiedTypeName.lastIndexOf("String_Node_Str");
  if (i == -1) {
    this.specifiedTypeSimpleName=specifiedTypeName;
    this.specifiedTypePackageName="String_Node_Str";
  }
 else {
    this.specifiedTypeSimpleName=specifiedTypeName.substring(i + 1);
    this.specifiedTypePackageName=specifiedTypeName.substring(0,i);
  }
}

Fixed version (ground truth):
public AbstractTypeCheck(String specifiedTypeName){
  if (specifiedTypeName == null || specifiedTypeName.trim().length() == 0) {
    throw new TransformationDefinitionException("String_Node_Str");
  }
  this.specifiedTypeName=specifiedTypeName;
  int i=specifiedTypeName.lastIndexOf("String_Node_Str");
  if (i == -1) {
    this.specifiedTypeSimpleName=specifiedTypeName;
    this.specifiedTypePackageName="String_Node_Str";
  }
 else {
    this.specifiedTypeSimpleName=specifiedTypeName.substring(i + 1);
    this.specifiedTypePackageName=specifiedTypeName.substring(0,i);
  }
}
Program: 39635
Project: 39635
Buggy source:
@Override protected ExecutionResult execution(File transformedAppFolder,TransformationContext transformationContext){
  File javaClassFile=getAbsoluteFile(transformedAppFolder,transformationContext);
  FileInputStream fileInputStream=null;
  TUExecutionResult result=null;
  try {
    fileInputStream=new FileInputStream(javaClassFile);
    CompilationUnit compilationUnit=JavaParser.parse(fileInputStream);
    if (compilationUnit.getTypes().size() == 0) {
      return TUExecutionResult.error(this,new TransformationUtilityException("String_Node_Str"));
    }
    boolean match=evaluate(compilationUnit);
    result=TUExecutionResult.value(this,match);
  }
 catch (  FileNotFoundException e) {
    result=TUExecutionResult.error(this,e);
  }
 finally {
    try {
      if (fileInputStream != null) {
        fileInputStream.close();
      }
    }
 catch (    IOException e) {
      result.addWarning(e);
    }
  }
  return result;
}

Fixed version (ground truth):
@Override protected ExecutionResult execution(File transformedAppFolder,TransformationContext transformationContext){
  File javaClassFile=getAbsoluteFile(transformedAppFolder,transformationContext);
  FileInputStream fileInputStream=null;
  TUExecutionResult result=null;
  try {
    fileInputStream=new FileInputStream(javaClassFile);
    CompilationUnit compilationUnit=JavaParser.parse(fileInputStream);
    if (compilationUnit.getTypes().size() == 0) {
      return TUExecutionResult.error(this,new TransformationUtilityException("String_Node_Str"));
    }
    boolean match=evaluate(compilationUnit);
    result=TUExecutionResult.value(this,match);
  }
 catch (  FileNotFoundException e) {
    result=TUExecutionResult.error(this,e);
  }
 finally {
    try {
      if (fileInputStream != null) {
        fileInputStream.close();
      }
    }
 catch (    IOException e) {
      if (result == null) {
        result=TUExecutionResult.error(this,e);
      }
 else {
        result.addWarning(e);
      }
    }
  }
  return result;
}
Program: 39637
Project: 39637
Buggy source:
/** 
 * Replace the text based on regex.
 * @param reader
 * @param writer
 * @param regex
 * @param replacement
 * @return String
 * @throws IOException
 */
private String replace(BufferedReader reader,BufferedWriter writer,String regex,String replacement) throws IOException {
  String currentLine;
  boolean foundFirstMatch=false;
  final Pattern pattern=Pattern.compile(regex + "String_Node_Str");
  boolean firstLine=true;
  while ((currentLine=reader.readLine()) != null) {
    if (!foundFirstMatch && pattern.matcher(currentLine).matches()) {
      foundFirstMatch=true;
      currentLine=currentLine.replaceAll("String_Node_Str",replacement);
    }
    if (!firstLine) {
      writer.write(System.lineSeparator());
    }
    writer.write(currentLine);
    firstLine=false;
  }
  return String.format("String_Node_Str",propertyName,propertyValue,getRelativePath());
}

Fixed version (ground truth):
/** 
 * Replace the text based on regex.
 * @param reader
 * @param writer
 * @param regex
 * @param replacement
 * @return String
 * @throws IOException
 */
private String replace(BufferedReader reader,BufferedWriter writer,String regex,String replacement) throws IOException {
  String currentLine;
  boolean foundFirstMatch=false;
  final Pattern pattern=Pattern.compile(regex + "String_Node_Str");
  EolBufferedReader eolReader=new EolBufferedReader(reader);
  while ((currentLine=eolReader.readLineKeepStartEOL()) != null) {
    if (!foundFirstMatch && pattern.matcher(removeEOL(currentLine)).matches()) {
      foundFirstMatch=true;
      currentLine=currentLine.replaceAll("String_Node_Str",replacement);
    }
    writer.write(currentLine);
  }
  return String.format("String_Node_Str",propertyName,propertyValue,getRelativePath());
}
Program: 39640
Project: 39640
Buggy source:
/** 
 * Return true only if a file has been set, either via   {@link #relative(String)} or {@link #absolute(String)}
 * @return
 */
public final boolean isFileSet(){
  return !(getRelativePath() == null && getAbsoluteFileFromContextAttribute() == null);
}

Fixed version (ground truth):
/** 
 * Return true only if a file has been set. Every   {@link TransformationUtility} has its file set automatically bydefault to "" which means the root of the application. That is NOT the case though for  {@link TransformationOperation}object, which must set them explicitly via   {@link #relative(String)} or {@link #absolute(String)}.
 * @return
 */
public final boolean isFileSet(){
  return !(getRelativePath() == null && getAbsoluteFileFromContextAttribute() == null);
}
Program: 39641
Project: 39641
Buggy source:
@Override protected TUExecutionResult execution(File transformedAppFolder,TransformationContext transformationContext){
  File searchRootFolder=getAbsoluteFile(transformedAppFolder,transformationContext);
  FindFiles findFiles=new FindFiles(fileName,true);
  TUExecutionResult result=null;
  List<File> files=(List<File>)findFiles.execution(searchRootFolder,transformationContext).getValue();
  if (files == null || files.size() == 0) {
    String details=String.format("String_Node_Str",fileName,getName());
    if (failIfNotFound) {
      TransformationUtilityException e=new TransformationUtilityException(details);
      result=TUExecutionResult.error(this,e);
    }
 else {
      result=TUExecutionResult.nullResult(this,details);
    }
  }
 else   if (files.size() > 1) {
    String exceptionMessage=String.format("String_Node_Str",fileName);
    TransformationUtilityException e=new TransformationUtilityException(exceptionMessage);
    result=TUExecutionResult.error(this,e);
  }
 else   if (files.size() == 1) {
    result=TUExecutionResult.value(this,files.get(0));
  }
  return result;
}

Fixed version (ground truth):
@Override protected TUExecutionResult execution(File transformedAppFolder,TransformationContext transformationContext){
  File searchRootFolder=getAbsoluteFile(transformedAppFolder,transformationContext);
  if (!searchRootFolder.exists()) {
    String details=String.format("String_Node_Str",fileName,getName());
    if (failIfNotFound) {
      TransformationUtilityException e=new TransformationUtilityException(details);
      return TUExecutionResult.error(this,e);
    }
 else {
      return TUExecutionResult.nullResult(this,details);
    }
  }
  FindFiles findFiles=new FindFiles(fileName,true);
  TUExecutionResult result=null;
  List<File> files=(List<File>)findFiles.execution(searchRootFolder,transformationContext).getValue();
  if (files == null || files.size() == 0) {
    String details=String.format("String_Node_Str",fileName,getName());
    if (failIfNotFound) {
      TransformationUtilityException e=new TransformationUtilityException(details);
      result=TUExecutionResult.error(this,e);
    }
 else {
      result=TUExecutionResult.nullResult(this,details);
    }
  }
 else   if (files.size() > 1) {
    String exceptionMessage=String.format("String_Node_Str",fileName);
    TransformationUtilityException e=new TransformationUtilityException(exceptionMessage);
    result=TUExecutionResult.error(this,e);
  }
 else   if (files.size() == 1) {
    result=TUExecutionResult.value(this,files.get(0));
  }
  return result;
}
Program: 39643
Project: 39643
Buggy source:
private TUExecutionResult setValue(Object value){
  if (value == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.value=value;
  return this;
}

Fixed version (ground truth):
private TUExecutionResult setValue(Object value){
  if (value == null && getType().equals(Type.VALUE)) {
    setType(Type.NULL);
    logger.warn("String_Node_Str",getSource().getName());
  }
  this.value=value;
  return this;
}
Program: 39646
Project: 39646
Buggy source:
@Override public String getDescription(){
  String executionCondition=iterations != -1 ? iterations + "String_Node_Str" : (attribute != null ? "String_Node_Str" + attribute + "String_Node_Str" : (condition != null ? "String_Node_Str" + condition.getName() + "String_Node_Str" : null));
  return String.format(DESCRIPTION,executionCondition);
}

Fixed version (ground truth):
@Override public String getDescription(){
  String executionCondition="String_Node_Str";
  if (iterations != -1) {
    executionCondition=iterations + "String_Node_Str";
  }
 else   if (attribute != null) {
    executionCondition="String_Node_Str" + attribute + "String_Node_Str";
  }
 else   if (condition != null) {
    executionCondition="String_Node_Str" + condition.getName() + "String_Node_Str";
  }
  return String.format(DESCRIPTION,executionCondition);
}
Program: 39647
Project: 39647
Buggy source:
@Override public TransformationUtility<MavenGoal> clone() throws CloneNotSupportedException {
  MavenGoal clone=(MavenGoal)super.clone();
  clone.outputHandlers=new MavenInvocationOutputHandler[outputHandlers.length];
  int i=0;
  for (  MavenInvocationOutputHandler outputHandler : outputHandlers) {
    clone.outputHandlers[i]=(MavenInvocationOutputHandler)outputHandler.copy();
    i++;
  }
  clone.request=new DefaultInvocationRequest();
  return clone;
}

Fixed version (ground truth):
@Override public TransformationUtility<MavenGoal> clone() throws CloneNotSupportedException {
  MavenGoal clone=(MavenGoal)super.clone();
  clone.multipleOutputHandler=new MultipleOutputHandler();
  clone.request=new DefaultInvocationRequest();
  clone.outputHandlers=new MavenInvocationOutputHandler[outputHandlers.length];
  int i=0;
  for (  MavenInvocationOutputHandler outputHandler : outputHandlers) {
    clone.outputHandlers[i]=(MavenInvocationOutputHandler)outputHandler.copy();
    i++;
  }
  return clone;
}
Program: 39651
Project: 39651
Buggy source:
/** 
 * Performs the transformation operation against the application to be transformed
 * @param transformedAppFolder
 * @param transformationContext
 * @return a message stating with details the operation that has been performed
 */
public final synchronized String perform(File transformedAppFolder,TransformationContext transformationContext) throws TransformationOperationException {
  if (hasBeenPerformed.get()) {
    throw new IllegalStateException("String_Node_Str");
  }
  try {
    applyPropertiesFromContext(transformationContext);
  }
 catch (  TransformationUtilityException e) {
    throw new TransformationOperationException(e.getMessage(),e);
  }
  if (conditionAttributeName != null && (Boolean)transformationContext.get(conditionAttributeName)) {
    return String.format("String_Node_Str",getName(),conditionAttributeName);
  }
  if (!preExecutionValidation(transformedAppFolder)) {
    throw new TransformationOperationException(getName() + "String_Node_Str");
  }
  String resultMessage;
  try {
    resultMessage=execution(transformedAppFolder,transformationContext);
  }
 catch (  Exception e) {
    throw new TransformationOperationException(getName() + "String_Node_Str",e);
  }
  hasBeenPerformed.set(true);
  return resultMessage;
}

Fixed version (ground truth):
/** 
 * Performs the transformation operation against the application to be transformed
 * @param transformedAppFolder
 * @param transformationContext
 * @return a message stating with details the operation that has been performed
 */
public final synchronized String perform(File transformedAppFolder,TransformationContext transformationContext) throws TransformationOperationException {
  if (hasBeenPerformed.get()) {
    throw new IllegalStateException("String_Node_Str");
  }
  try {
    applyPropertiesFromContext(transformationContext);
  }
 catch (  TransformationUtilityException e) {
    throw new TransformationOperationException(e.getMessage(),e);
  }
  if (conditionAttributeName != null && !(Boolean)transformationContext.get(conditionAttributeName)) {
    return String.format("String_Node_Str",getName(),conditionAttributeName);
  }
  if (!preExecutionValidation(transformedAppFolder)) {
    throw new TransformationOperationException(getName() + "String_Node_Str");
  }
  String resultMessage;
  try {
    resultMessage=execution(transformedAppFolder,transformationContext);
  }
 catch (  Exception e) {
    throw new TransformationOperationException(getName() + "String_Node_Str",e);
  }
  hasBeenPerformed.set(true);
  return resultMessage;
}
Program: 39652
Project: 39652
Buggy source:
public static String getCurrentTimeStamp(){
  return simpleDateFormat.format(new Date());
}

Fixed version (ground truth):
public String getCurrentTimeStamp(){
  return simpleDateFormat.format(new Date());
}
Program: 39654
Project: 39654
Buggy source:
@Override public String getDescription(){
  return String.format(DESCRIPTION,fileName,(getRelativePath() == "String_Node_Str" ? "String_Node_Str" : getRelativePath()));
}

Fixed version (ground truth):
@Override public String getDescription(){
  return String.format(DESCRIPTION,fileName,("String_Node_Str".equals(getRelativePath()) ? "String_Node_Str" : getRelativePath()));
}
Program: 39658
Project: 39658
Buggy source:
private String removeBasedOnRegex(File fileToBeChanged) throws Exception {
  File tempFile=new File(fileToBeChanged.getAbsolutePath() + "String_Node_Str" + System.currentTimeMillis());
  BufferedReader reader=null;
  BufferedWriter writer=null;
  int n=0;
  try {
    reader=new BufferedReader(new FileReader(fileToBeChanged));
    writer=new BufferedWriter(new FileWriter(tempFile));
    String currentLine;
    boolean foundFirstMatch=false;
    final Pattern pattern=Pattern.compile(regex);
    while ((currentLine=reader.readLine()) != null) {
      if ((!firstOnly || !foundFirstMatch) && pattern.matcher(currentLine).matches()) {
        foundFirstMatch=true;
        n++;
        continue;
      }
      writer.write(currentLine);
      writer.write(System.lineSeparator());
    }
  }
  finally {
    if (writer != null)     writer.close();
    if (reader != null)     reader.close();
  }
  boolean successful=tempFile.renameTo(fileToBeChanged);
  return String.format("String_Node_Str",getRelativePath(),n,regex);
}

Fixed version (ground truth):
private String removeBasedOnRegex(File fileToBeChanged) throws Exception {
  File tempFile=new File(fileToBeChanged.getAbsolutePath() + "String_Node_Str" + System.currentTimeMillis());
  BufferedReader reader=null;
  BufferedWriter writer=null;
  int n=0;
  try {
    reader=new BufferedReader(new InputStreamReader(new FileInputStream(fileToBeChanged),StandardCharsets.UTF_8));
    writer=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(tempFile),StandardCharsets.UTF_8));
    String currentLine;
    boolean foundFirstMatch=false;
    final Pattern pattern=Pattern.compile(regex);
    while ((currentLine=reader.readLine()) != null) {
      if ((!firstOnly || !foundFirstMatch) && pattern.matcher(currentLine).matches()) {
        foundFirstMatch=true;
        n++;
        continue;
      }
      writer.write(currentLine);
      writer.write(System.lineSeparator());
    }
  }
  finally {
    if (writer != null)     writer.close();
    if (reader != null)     reader.close();
  }
  boolean successful=tempFile.renameTo(fileToBeChanged);
  return String.format("String_Node_Str",getRelativePath(),n,regex);
}
Program: 39659
Project: 39659
Buggy source:
private String removeBasedOnLineNumber(File fileToBeChanged) throws Exception {
  File tempFile=new File(fileToBeChanged.getAbsolutePath() + "String_Node_Str" + System.currentTimeMillis());
  BufferedReader reader=null;
  BufferedWriter writer=null;
  int n=0;
  try {
    reader=new BufferedReader(new FileReader(fileToBeChanged));
    writer=new BufferedWriter(new FileWriter(tempFile));
    String currentLine;
    while ((currentLine=reader.readLine()) != null) {
      n++;
      if (n == lineNumber) {
        continue;
      }
      writer.write(currentLine);
      writer.write(System.lineSeparator());
    }
  }
  finally {
    if (writer != null)     writer.close();
    if (reader != null)     reader.close();
  }
  boolean successful=tempFile.renameTo(fileToBeChanged);
  return String.format("String_Node_Str",getRelativePath(),lineNumber);
}

Fixed version (ground truth):
private String removeBasedOnLineNumber(File fileToBeChanged) throws Exception {
  File tempFile=new File(fileToBeChanged.getAbsolutePath() + "String_Node_Str" + System.currentTimeMillis());
  BufferedReader reader=null;
  BufferedWriter writer=null;
  int n=0;
  try {
    reader=new BufferedReader(new InputStreamReader(new FileInputStream(fileToBeChanged),StandardCharsets.UTF_8));
    writer=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(tempFile),StandardCharsets.UTF_8));
    String currentLine;
    while ((currentLine=reader.readLine()) != null) {
      n++;
      if (n == lineNumber) {
        continue;
      }
      writer.write(currentLine);
      writer.write(System.lineSeparator());
    }
  }
  finally {
    if (writer != null)     writer.close();
    if (reader != null)     reader.close();
  }
  boolean successful=tempFile.renameTo(fileToBeChanged);
  return String.format("String_Node_Str",getRelativePath(),lineNumber);
}
Program: 39660
Project: 39660
Buggy source:
public static String getCurrentTimeStamp(){
  return simpleDateFormat.format(new Date());
}

Fixed version (ground truth):
public String getCurrentTimeStamp(){
  return simpleDateFormat.format(new Date());
}
Program: 39661
Project: 39661
Buggy source:
/** 
 * This method allows setting properties in this transformation utility during transformation time, right before its execution. This is very useful when the property value is not known during transformation definition. Any attribute stored in the transformation context can be used as the value to be set to the property. In most of the cases the result of a prior transformation utility is used as property value. Notice that, because this feature relies on reflection, it is not cheap, especially because it happens during transformation time. So, use it only when really necessary.
 * @param propertyName the transformation utility Java bean property name
 * @param contextAttributeName the name of the transformation context attribute whosevalue will be set as the property value right before execution
 * @return this transformation utility
 */
public final TU set(String propertyName,String contextAttributeName){
  validateProperty(propertyName);
  lateProperties.put(propertyName,contextAttributeName);
  return (TU)this;
}

Fixed version (ground truth):
/** 
 * This method allows setting properties in this transformation utility during transformation time, right before its execution. This is very useful when the property value is not known during transformation definition. Any attribute stored in the transformation context can be used as the value to be set to the property. In most of the cases the result of a prior transformation utility is used as property value. Notice that, because this feature relies on reflection, it is not cheap, especially because it happens during transformation time. So, use it only when really necessary.
 * @param propertyName the transformation utility Java bean property name
 * @param contextAttributeName the name of the transformation context attribute whosevalue will be set as the property value right before execution
 * @return this transformation utility
 */
public final TU set(String propertyName,String contextAttributeName){
  Method method=getMethod(propertyName);
  latePropertiesAttributes.put(propertyName,contextAttributeName);
  latePropertiesSetters.put(propertyName,method);
  return (TU)this;
}
Program: 39662
Project: 39662
Buggy source:
/** 
 * Applies transformation utility properties during transformation time, but prior to execution (right before it). The properties values are gotten from the transformation context object.
 * @param transformationContext
 */
protected final void applyPropertiesFromContext(TransformationContext transformationContext) throws TransformationUtilityException {
  String attributeName;
  Method method;
  String methodName;
  for (  String propertyName : lateProperties.keySet()) {
    attributeName=lateProperties.get(propertyName);
    try {
      methodName=getMethodName(propertyName);
      method=((TU)this).getClass().getMethod(methodName);
      Object value=transformationContext.get(attributeName);
      method.invoke(this,value);
    }
 catch (    Exception e) {
      String exceptionMessage=String.format("String_Node_Str",propertyName,attributeName,name);
      logger.error(exceptionMessage,e);
      throw new TransformationUtilityException(exceptionMessage,e);
    }
  }
}

Fixed version (ground truth):
/** 
 * Applies transformation utility properties during transformation time, but prior to execution (right before it). The properties values are gotten from the transformation context object.
 * @param transformationContext
 */
protected final void applyPropertiesFromContext(TransformationContext transformationContext) throws TransformationUtilityException {
  String attributeName;
  Method method;
  for (  String propertyName : latePropertiesAttributes.keySet()) {
    attributeName=latePropertiesAttributes.get(propertyName);
    try {
      method=latePropertiesSetters.get(propertyName);
      Object value=transformationContext.get(attributeName);
      method.invoke(this,value);
    }
 catch (    Exception e) {
      String exceptionMessage=String.format("String_Node_Str",propertyName,attributeName,name);
      logger.error(exceptionMessage,e);
      throw new TransformationUtilityException(exceptionMessage,e);
    }
  }
}
Program: 39663
Project: 39663
Buggy source:
@Override protected String execution(File transformedAppFolder,TransformationContext transformationContext) throws Exception {
  File p=new File(transformedAppFolder.toString());
  File pomFile=getAbsoluteFile(p,transformationContext);
  String resultMessage=null;
  MavenXpp3Reader reader=new MavenXpp3Reader();
  Model model=reader.read(new FileInputStream(pomFile));
  boolean found=false;
  if (groupId != null || artifactId != null) {
    List deps=model.getDependencyManagement().getDependencies();
    for (int i=0; i < deps.size(); i++) {
      if (((Dependency)deps.get(i)).getArtifactId().equals(artifactId) && ((Dependency)deps.get(i)).getGroupId().equals(groupId)) {
        model.getDependencyManagement().removeDependency((Dependency)deps.get(i));
        resultMessage=String.format("String_Node_Str",groupId,artifactId,getRelativePath());
        found=true;
        break;
      }
    }
    if (!found) {
      resultMessage=String.format("String_Node_Str",groupId,artifactId,getRelativePath());
    }
  }
 else {
    throw new IllegalStateException("String_Node_Str");
  }
  MavenXpp3Writer writer=new MavenXpp3Writer();
  writer.write(new FileOutputStream(pomFile),model);
  return resultMessage;
}

Fixed version (ground truth):
@Override protected String execution(File transformedAppFolder,TransformationContext transformationContext) throws Exception {
  File pomFile=getAbsoluteFile(transformedAppFolder,transformationContext);
  String resultMessage=null;
  MavenXpp3Reader reader=new MavenXpp3Reader();
  Model model=reader.read(new FileInputStream(pomFile));
  boolean found=false;
  DependencyManagement dependencyManagement=model.getDependencyManagement();
  if (dependencyManagement != null) {
    for (    Dependency dependency : dependencyManagement.getDependencies()) {
      if (dependency.getArtifactId().equals(artifactId) && dependency.getGroupId().equals(groupId)) {
        dependencyManagement.removeDependency(dependency);
        resultMessage=String.format("String_Node_Str",groupId,artifactId,getRelativePath());
        MavenXpp3Writer writer=new MavenXpp3Writer();
        writer.write(new FileOutputStream(pomFile),model);
        found=true;
        break;
      }
    }
  }
  if (!found) {
    resultMessage=String.format("String_Node_Str",groupId,artifactId,getRelativePath());
  }
  return resultMessage;
}
Program: 39664
Project: 39664
Buggy source:
@Override protected String execution(File transformedAppFolder,TransformationContext transformationContext) throws Exception {
  return String.format(format,attributeNames);
}

Fixed version (ground truth):
@Override protected String execution(File transformedAppFolder,TransformationContext transformationContext) throws Exception {
  String[] attributeValues=new String[attributeNames.length];
  String attributeName;
  for (int i=0; i < attributeNames.length; i++) {
    attributeValues[i]=(String)transformationContext.get(attributeNames[i]);
  }
  return String.format(format,attributeValues);
}
Program: 39665
Project: 39665
Buggy source:
private void setAbsoluteFile(File transformedAppFolder,TransformationContext transformationContext){
  if (absoluteFileFromContextAttribute != null) {
    absoluteFile=(File)transformationContext.get(absoluteFileFromContextAttribute);
    relativePath=absoluteFile.getAbsolutePath().split(transformedAppFolder.getAbsolutePath())[1];
    logger.debug("String_Node_Str",name,absoluteFileFromContextAttribute,absoluteFile.getAbsolutePath());
    logger.debug("String_Node_Str",name,relativePath);
  }
 else {
    absoluteFile=new File(transformedAppFolder,getRelativePath());
  }
}

Fixed version (ground truth):
private void setAbsoluteFile(File transformedAppFolder,TransformationContext transformationContext){
  if (absoluteFileFromContextAttribute != null) {
    absoluteFile=(File)transformationContext.get(absoluteFileFromContextAttribute);
    setRelativePath(transformedAppFolder,absoluteFile);
    logger.debug("String_Node_Str",name,absoluteFileFromContextAttribute,absoluteFile.getAbsolutePath());
    logger.debug("String_Node_Str",name,relativePath);
  }
 else {
    absoluteFile=new File(transformedAppFolder,getRelativePath());
  }
}
Program: 39666
Project: 39666
Buggy source:
/** 
 * Sets the relative path from the application root folder to the file or folder the transformation utility should perform against. Three options are valid when separating folders in the path: <ol> <li>1-File.separatorChar (e.g. setRelativePath("myFolder" + File.separator + "file.txt")</li> <li>2-Forward slash (e.g. setRelativePath("myFolder/file.txt")</li> <li>3-Two backward slashes (e.g. setRelativePath("myFolder\\file.txt")</li> </ol> The slashes are replaced by OS specific separator char in runtime.
 * @param relativePath from the application root folderto the file or folder the transformation utility should be performed against
 * @return this transformation utility
 */
public final TU setRelativePath(String relativePath){
  if (relativePath != null) {
    this.relativePath=relativePath.replace('/',File.separatorChar).replace('\\',File.separatorChar);
  }
  return (TU)this;
}

Fixed version (ground truth):
private void setRelativePath(File transformedAppFolder,File absoluteFile){
  int beginning=transformedAppFolder.getAbsolutePath().length();
  int end=absoluteFile.getAbsolutePath().length();
  relativePath=absoluteFile.getAbsolutePath().substring(beginning,end);
}
Program: 39667
Project: 39667
Buggy source:
private static void printExtensionsList(ButterflyFacade butterflyFacade) throws IllegalAccessException, InstantiationException {
  Set<Extension> registeredExtensions=butterflyFacade.getRegisteredExtensions();
  Extension extension;
  Class<? extends TransformationTemplate> template;
  for (  Object extensionObj : registeredExtensions.toArray()) {
    extension=(Extension)extensionObj;
    System.out.printf("String_Node_Str",extension,extension.getDescription());
    for (    Object templateObj : extension.getTemplateClasses().toArray()) {
      template=(Class<? extends TransformationTemplate>)templateObj;
      System.out.printf("String_Node_Str",ExtensionTypeInitial.getFromClass(template),template.getName(),template.newInstance().getDescription());
    }
  }
}

Fixed version (ground truth):
private static void printExtensionsList(ButterflyFacade butterflyFacade) throws IllegalAccessException, InstantiationException {
  Set<Extension> registeredExtensions=butterflyFacade.getRegisteredExtensions();
  if (registeredExtensions.size() == 0) {
    logger.info("String_Node_Str");
    return;
  }
  logger.info("String_Node_Str");
  Extension extension;
  Class<? extends TransformationTemplate> template;
  for (  Object extensionObj : registeredExtensions.toArray()) {
    extension=(Extension)extensionObj;
    System.out.printf("String_Node_Str",extension,extension.getDescription());
    for (    Object templateObj : extension.getTemplateClasses().toArray()) {
      template=(Class<? extends TransformationTemplate>)templateObj;
      System.out.printf("String_Node_Str",ExtensionTypeInitial.getFromClass(template),template.getName(),template.newInstance().getDescription());
    }
  }
}
Program: 39668
Project: 39668
Buggy source:
public static void main(String... arguments) throws IOException {
  ConfigurableApplicationContext applicationContext=SpringApplication.run(ButterflyCliApp.class,arguments);
  logger.info(BANNER);
  OptionParser optionParser=createOptionSet();
  OptionSet optionSet=null;
  if (arguments.length != 0) {
    optionSet=optionParser.parse(arguments);
  }
  if (optionSet != null && optionSet.has(CLI_OPTION_VERBOSE)) {
    VerboseConfigurator verboseConfigurator=applicationContext.getBean(VerboseConfigurator.class);
    verboseConfigurator.verboseMode(true);
    logger.debug("String_Node_Str");
  }
  if (optionSet == null || optionSet.has(CLI_OPTION_HELP) || !optionSet.hasOptions()) {
    logger.info("String_Node_Str");
    optionParser.printHelpOn(System.out);
    return;
  }
  File applicationFolder=(File)optionSet.valueOf("String_Node_Str");
  String templateClassName=(String)optionSet.valueOf("String_Node_Str");
  ButterflyFacade butterflyFacade=applicationContext.getBean(ButterflyFacade.class);
  if (optionSet.has(CLI_OPTION_LIST_EXTENSIONS)) {
    logger.info("String_Node_Str");
    try {
      printExtensionsList(butterflyFacade);
    }
 catch (    Exception e) {
      logger.error("String_Node_Str",e);
    }
    return;
  }
  try {
    butterflyFacade.transform(applicationFolder,templateClassName);
    logger.info("String_Node_Str");
  }
 catch (  TransformationException e) {
    logger.error("String_Node_Str",e);
  }
catch (  ButterflyException e) {
    logger.error("String_Node_Str",e);
  }
}

Fixed version (ground truth):
public static void main(String... arguments) throws IOException {
  ConfigurableApplicationContext applicationContext=SpringApplication.run(ButterflyCliApp.class,arguments);
  logger.info(BANNER);
  OptionParser optionParser=createOptionSet();
  OptionSet optionSet=null;
  if (arguments.length != 0) {
    optionSet=optionParser.parse(arguments);
  }
  if (optionSet != null && optionSet.has(CLI_OPTION_VERBOSE)) {
    VerboseConfigurator verboseConfigurator=applicationContext.getBean(VerboseConfigurator.class);
    verboseConfigurator.verboseMode(true);
    logger.debug("String_Node_Str");
  }
  if (optionSet == null || optionSet.has(CLI_OPTION_HELP) || !optionSet.hasOptions()) {
    logger.info("String_Node_Str");
    optionParser.printHelpOn(System.out);
    return;
  }
  File applicationFolder=(File)optionSet.valueOf("String_Node_Str");
  String templateClassName=(String)optionSet.valueOf("String_Node_Str");
  ButterflyFacade butterflyFacade=applicationContext.getBean(ButterflyFacade.class);
  if (optionSet.has(CLI_OPTION_LIST_EXTENSIONS)) {
    try {
      printExtensionsList(butterflyFacade);
    }
 catch (    Exception e) {
      logger.error("String_Node_Str",e);
    }
    return;
  }
  try {
    butterflyFacade.transform(applicationFolder,templateClassName);
    logger.info("String_Node_Str");
  }
 catch (  TransformationException e) {
    logger.error("String_Node_Str",e);
  }
catch (  ButterflyException e) {
    logger.error("String_Node_Str",e);
  }
}
Program: 39669
Project: 39669
Buggy source:
private void setExtensions(){
  logger.debug("String_Node_Str");
  Set<Class<? extends Extension>> extensionClasses=findExtensionClasses();
  logger.debug("String_Node_Str" + extensionClasses.size());
  logger.debug("String_Node_Str");
  registerExtensions(extensionClasses);
  logger.debug("String_Node_Str");
}

Fixed version (ground truth):
private void setExtensions(){
  logger.info("String_Node_Str");
  Set<Class<? extends Extension>> extensionClasses=findExtensionClasses();
  logger.info("String_Node_Str" + extensionClasses.size());
  if (extensionClasses.size() == 0) {
    extensions=Collections.emptySet();
    return;
  }
  logger.debug("String_Node_Str");
  registerExtensions(extensionClasses);
  logger.debug("String_Node_Str");
}
Program: 39670
Project: 39670
Buggy source:
public static List<Integer> sieveOfErathostenes(int n){
  if (n < 2) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Set<Integer> numbers=new HashSet<>(n);
  for (int i=2; i <= n; i++) {
    numbers.add(i);
  }
  for (int i=2; i <= Math.sqrt((double)n); i++) {
    if (numbers.contains(i)) {
      for (int j=i * i; j <= n; j+=i) {
        numbers.remove(j);
      }
    }
  }
  return new ArrayList<>(numbers);
}

Fixed version (ground truth):
public static List<Integer> sieveOfErathostenes(int n){
  if (n < 2) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Set<Integer> numbers=new HashSet<>(n);
  for (int i=2; i <= n && i >= 2; i++) {
    numbers.add(i);
  }
  for (int i=2; i <= Math.sqrt((double)n); i++) {
    if (numbers.contains(i)) {
      for (int j=i * i; j <= n && j > 0; j+=i) {
        numbers.remove(j);
      }
    }
  }
  return new ArrayList<>(numbers);
}
Program: 39671
Project: 39671
Buggy source:
public static List<Integer> sieveOfErathostenesBitSet(int n){
  if (n < 2) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  BitSet numbers=new BitSet(n);
  for (int i=2; i <= n; i++) {
    numbers.set(i);
  }
  for (int i=2; i <= Math.sqrt((double)n); i++) {
    if (numbers.get(i)) {
      for (int j=i * i; j <= n; j+=i) {
        numbers.clear(j);
      }
    }
  }
  List<Integer> result=new ArrayList<>(numbers.cardinality());
  for (int i=numbers.nextSetBit(0); i >= 0; i=numbers.nextSetBit(i + 1)) {
    result.add(i);
    if (i == Integer.MAX_VALUE) {
      break;
    }
  }
  return result;
}

Fixed version (ground truth):
public static List<Integer> sieveOfErathostenesBitSet(int n){
  if (n < 2) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  BitSet numbers=new BitSet(n);
  for (int i=2; i <= n && i >= 2; i++) {
    numbers.set(i);
  }
  for (int i=2; i <= Math.sqrt((double)n); i++) {
    if (numbers.get(i)) {
      for (int j=i * i; j <= n && j >= 0; j+=i) {
        numbers.clear(j);
      }
    }
  }
  List<Integer> result=new ArrayList<>(numbers.cardinality());
  for (int i=numbers.nextSetBit(0); i >= 0; i=numbers.nextSetBit(i + 1)) {
    result.add(i);
    if (i == Integer.MAX_VALUE) {
      break;
    }
  }
  return result;
}
Program: 39672
Project: 39672
Buggy source:
public static void main(String[] args){
  Random r=new Random(System.currentTimeMillis());
  List<Integer> possibles=new ArrayList<>(50);
  for (int i=1; i <= 49; i++) {
    possibles.add(i);
  }
  List<Integer> picked=new ArrayList<>(6);
  for (int i=0; i < 6; i++) {
    int pickIndex=r.nextInt(49);
    picked.add(possibles.remove(pickIndex));
  }
  Collections.sort(picked);
  for (  int i : picked) {
    System.out.printf("String_Node_Str",i);
  }
  System.out.println();
}

Fixed version (ground truth):
public static void main(String[] args){
  final int size=49;
  Random r=new Random(System.currentTimeMillis());
  List<Integer> possibles=new ArrayList<>(size + 1);
  for (int i=1; i <= size; i++) {
    possibles.add(i);
  }
  List<Integer> picked=new ArrayList<>(6);
  for (int i=0; i < 6; i++) {
    int pickIndex=r.nextInt(size - i);
    picked.add(possibles.remove(pickIndex));
  }
  Collections.sort(picked);
  for (  int i : picked) {
    System.out.printf("String_Node_Str",i);
  }
  System.out.println();
}
Program: 39674
Project: 39674
Buggy source:
@Nonnull final JavaFileObject fixture(@Nonnull final String path){
  try {
    return JavaFileObjects.forResource(fixtureDir().resolve(path).toUri().toURL());
  }
 catch (  final MalformedURLException e) {
    throw new IllegalStateException(e);
  }
}

Fixed version (ground truth):
@Nonnull final JavaFileObject fixture(@Nonnull final String path){
  final Path outputFile=fixtureDir().resolve(path);
  if (!Files.exists(outputFile)) {
    fail("String_Node_Str" + outputFile + "String_Node_Str");
  }
  try {
    return JavaFileObjects.forResource(outputFile.toUri().toURL());
  }
 catch (  final MalformedURLException e) {
    throw new IllegalStateException(e);
  }
}