nus-yam/ex-repair huggingface dataset:
Program: 141169
Project: 141169
Buggy source:
@Override public boolean compareFiles(BloomFilterUtils filter,InputStream is) throws IOException {
  final BufferedReader reader=new BufferedReader(new InputStreamReader(is));
  String line=null;
  numberElementsCompared=0;
  while ((line=reader.readLine()) != null) {
    numberElementsCompared++;
    if (!filter.mightContain(line)) {
      setCauseFailComparison(line);
      reader.close();
      return false;
    }
  }
  reader.close();
  if (numberElementsCompared != filter.getAddedNumberOfElements()) {
    setCauseFailComparison("String_Node_Str" + this.numberElementsCompared + "String_Node_Str"+ filter.getAddedNumberOfElements()+ "String_Node_Str");
    return false;
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean compareFiles(BloomFilterUtils filter,InputStream is) throws IOException {
  final BufferedReader reader=new BufferedReader(new InputStreamReader(is,Globals.DEFAULT_CHARSET));
  String line=null;
  numberElementsCompared=0;
  while ((line=reader.readLine()) != null) {
    numberElementsCompared++;
    if (!filter.mightContain(line)) {
      setCauseFailComparison(line);
      reader.close();
      return false;
    }
  }
  reader.close();
  if (numberElementsCompared != filter.getAddedNumberOfElements()) {
    setCauseFailComparison("String_Node_Str" + this.numberElementsCompared + "String_Node_Str"+ filter.getAddedNumberOfElements()+ "String_Node_Str");
    return false;
  }
  return true;
}
Program: 141171
Project: 141171
Buggy source:
/** 
 * Public constructor.
 * @param file output file
 */
public TSVTranslatorOutputFormat(final File file) throws IOException {
  this.writer=new BufferedWriter(new FileWriter(file));
}

Fixed version (ground truth):
/** 
 * Public constructor.
 * @param file output file
 */
public TSVTranslatorOutputFormat(final File file) throws IOException {
  this.writer=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file),Globals.DEFAULT_CHARSET));
}
Program: 141172
Project: 141172
Buggy source:
@Override protected void clean(){
  tmpFile1.delete();
  tmpFile2.delete();
}

Fixed version (ground truth):
@Override protected void clean(){
  if (tmpFile1.delete()) {
    getLogger().warning("String_Node_Str" + tmpFile1);
  }
  if (tmpFile2.delete()) {
    getLogger().warning("String_Node_Str" + tmpFile2);
  }
}
Program: 141173
Project: 141173
Buggy source:
private MapperProcess createMapperProcessSE(final String bwaPath,final String indexPath,final File readsFile,final File tmpFile,final boolean fileMode) throws IOException {
  return new MapperProcess(this,fileMode,false,false){
    @Override protected List<List<String>> createCommandLines(){
      final boolean illuminaFastq=getFastqFormat() == FASTQ_ILLUMINA || getFastqFormat() == FASTQ_ILLUMINA_1_5;
      final List<String> cmd1=new ArrayList<String>();
      cmd1.add(bwaPath);
      cmd1.add("String_Node_Str");
      if (illuminaFastq)       cmd1.add("String_Node_Str");
      cmd1.add(getMapperArguments());
      cmd1.add("String_Node_Str");
      cmd1.add(getThreadsNumber() + "String_Node_Str");
      cmd1.add("String_Node_Str");
      cmd1.add(tmpFile.getAbsolutePath());
      cmd1.add(indexPath);
      if (fileMode)       cmd1.add(readsFile.getAbsolutePath());
 else       cmd1.add(getTmpInputFile1().getAbsolutePath());
      final List<String> cmd2=new ArrayList<String>();
      cmd2.add(bwaPath);
      cmd2.add("String_Node_Str");
      cmd2.add(indexPath);
      cmd2.add(tmpFile.getAbsolutePath());
      if (fileMode)       cmd2.add(readsFile.getAbsolutePath());
 else       cmd2.add(getTmpInputFile1().getAbsolutePath());
      final List<List<String>> result=new ArrayList<List<String>>();
      result.add(cmd1);
      result.add(cmd2);
      return result;
    }
    @Override protected void clean(){
      tmpFile.delete();
    }
  }
;
}

Fixed version (ground truth):
private MapperProcess createMapperProcessSE(final String bwaPath,final String indexPath,final File readsFile,final File tmpFile,final boolean fileMode) throws IOException {
  return new MapperProcess(this,fileMode,false,false){
    @Override protected List<List<String>> createCommandLines(){
      final boolean illuminaFastq=getFastqFormat() == FASTQ_ILLUMINA || getFastqFormat() == FASTQ_ILLUMINA_1_5;
      final List<String> cmd1=new ArrayList<String>();
      cmd1.add(bwaPath);
      cmd1.add("String_Node_Str");
      if (illuminaFastq)       cmd1.add("String_Node_Str");
      cmd1.add(getMapperArguments());
      cmd1.add("String_Node_Str");
      cmd1.add(getThreadsNumber() + "String_Node_Str");
      cmd1.add("String_Node_Str");
      cmd1.add(tmpFile.getAbsolutePath());
      cmd1.add(indexPath);
      if (fileMode)       cmd1.add(readsFile.getAbsolutePath());
 else       cmd1.add(getTmpInputFile1().getAbsolutePath());
      final List<String> cmd2=new ArrayList<String>();
      cmd2.add(bwaPath);
      cmd2.add("String_Node_Str");
      cmd2.add(indexPath);
      cmd2.add(tmpFile.getAbsolutePath());
      if (fileMode)       cmd2.add(readsFile.getAbsolutePath());
 else       cmd2.add(getTmpInputFile1().getAbsolutePath());
      final List<List<String>> result=new ArrayList<List<String>>();
      result.add(cmd1);
      result.add(cmd2);
      return result;
    }
    @Override protected void clean(){
      if (!tmpFile.delete()) {
        getLogger().warning("String_Node_Str" + tmpFile);
      }
    }
  }
;
}
Program: 141175
Project: 141175
Buggy source:
/** 
 * Custom splitter for Casava tabulated file.
 * @param line line to parse
 * @return a list of String with the contents of each cell without unnecessaryquotes
 */
public static List<String> parseTabulatedDesignLine(final String line){
  if (s == null)   return null;
  return Arrays.asList(s.split("String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * Custom splitter for Casava tabulated file.
 * @param line line to parse
 * @return a list of String with the contents of each cell without unnecessaryquotes
 */
public static List<String> parseTabulatedDesignLine(final String line){
  if (line == null)   return null;
  return Arrays.asList(line.split("String_Node_Str"));
}
Program: 141177
Project: 141177
Buggy source:
private boolean isDataFormatExtension(final DataFormat dataFormat,final String extension,DataFileMetadata md){
  if (md != null && md.getDataFormat() != null && dataFormat.equals(md.getDataFormat()))   return true;
  return dfr.getDataFormatFromExtension(extension) != null;
}

Fixed version (ground truth):
private boolean isDataFormatExtension(final DataFormat dataFormat,final String extension,DataFileMetadata md){
  if (md != null && md.getDataFormat() != null) {
    return dataFormat.equals(md.getDataFormat());
  }
  return dfr.getDataFormatFromExtension(extension) == dataFormat;
}
Program: 141178
Project: 141178
Buggy source:
/** 
 * Get the AbstractData object wrapped by this object.
 * @return the AbstractData object wrapped by this object
 */
AbstractData getData(){
  Data data=this;
  do {
    data=((UnmodifiableData)data).data;
  }
 while (data instanceof UnmodifiableData);
  return (AbstractData)this.data;
}

Fixed version (ground truth):
/** 
 * Get the AbstractData object wrapped by this object.
 * @return the AbstractData object wrapped by this object
 */
AbstractData getData(){
  Data data=this;
  do {
    data=((UnmodifiableData)data).data;
  }
 while (data instanceof UnmodifiableData);
  return (AbstractData)data;
}
Program: 141179
Project: 141179
Buggy source:
/** 
 * Add data to the token manager.
 * @param inputPort inputPort port for the data
 * @param data the data
 */
private void addData(final WorkflowInputPort inputPort,final Data data){
  if (!inputPort.isList()) {
synchronized (this) {
      inputTokens.put(inputPort,data);
    }
  }
 else {
    final DataList dataList;
    final Collection<Data> inputData=this.inputTokens.get(inputPort);
    if (inputData.size() == 0) {
      dataList=new DataList(inputPort);
    }
 else {
      dataList=(DataList)inputData.iterator().next();
    }
    dataList.getModifiableList().add(data);
  }
}

Fixed version (ground truth):
/** 
 * Add data to the token manager.
 * @param inputPort inputPort port for the data
 * @param data the data
 */
private void addData(final WorkflowInputPort inputPort,final Data data){
  if (!inputPort.isList()) {
synchronized (this) {
      inputTokens.put(inputPort,data);
    }
  }
 else {
    final DataList dataList;
    final Collection<Data> inputData=this.inputTokens.get(inputPort);
    if (inputData.size() == 0) {
      dataList=new DataList(inputPort);
      inputData.add(dataList);
    }
 else {
      dataList=(DataList)inputData.iterator().next();
    }
    dataList.getModifiableList().add(data);
  }
}
Program: 141180
Project: 141180
Buggy source:
/** 
 * Post a token to the the token manager.
 * @param inputPort port where the token must be posted
 * @param token the token to post
 */
public void postToken(final WorkflowInputPort inputPort,final Token token){
  checkNotNull(token);
  checkNotNull(inputPort);
  final StepState originStepState=token.getOrigin().getStep().getState();
  checkState(originStepState == WORKING || originStepState == DONE,"String_Node_Str" + originStepState);
  checkState(!this.receivedToken.contains(token.getId()),"String_Node_Str" + token.getId());
  checkState(this.inputPorts.contains(inputPort),"String_Node_Str" + inputPort);
  checkState(inputPort.getLink() == token.getOrigin(),"String_Node_Str" + inputPort + "String_Node_Str"+ outputPorts+ "String_Node_Str");
  checkState(!this.closedPorts.contains(inputPort),"String_Node_Str" + inputPort);
  if (token.isEndOfStepToken()) {
    checkState(!this.inputTokens.get(inputPort).isEmpty(),"String_Node_Str" + inputPort);
    this.closedPorts.add(inputPort);
  }
 else {
    final Data data=token.getData();
    if (data.isList())     for (    Data e : data.getListElements())     addData(inputPort,e);
 else     addData(inputPort,data);
  }
}

Fixed version (ground truth):
/** 
 * Post a token to the the token manager.
 * @param inputPort port where the token must be posted
 * @param token the token to post
 */
public void postToken(final WorkflowInputPort inputPort,final Token token){
  checkNotNull(token);
  checkNotNull(inputPort);
  final StepState originStepState=token.getOrigin().getStep().getState();
  checkState(originStepState == WORKING || originStepState == DONE,"String_Node_Str" + originStepState);
  checkState(!this.receivedToken.contains(token.getId()),"String_Node_Str" + token.getId());
  checkState(this.inputPorts.contains(inputPort),"String_Node_Str" + inputPort);
  checkState(inputPort.getLink() == token.getOrigin(),"String_Node_Str" + inputPort + "String_Node_Str"+ token.getOrigin()+ "String_Node_Str");
  checkState(!this.closedPorts.contains(inputPort),"String_Node_Str" + this.step.getId() + "String_Node_Str"+ inputPort.getName());
  if (token.isEndOfStepToken()) {
    checkState(!this.inputTokens.get(inputPort).isEmpty(),"String_Node_Str" + this.step.getId() + "String_Node_Str"+ inputPort.getName());
    this.closedPorts.add(inputPort);
  }
 else {
    final Data data=token.getData();
    if (data.isList()) {
      for (      Data e : data.getListElements()) {
        addData(inputPort,e);
      }
    }
 else {
      addData(inputPort,data);
    }
  }
}
Program: 141181
Project: 141181
Buggy source:
/** 
 * Constructor.
 * @param step step related to the context
 */
WorkflowStepContext(final WorkflowContext workflowContext,final AbstractWorkflowStep step,Map<InputPort,Data> inputData,Map<OutputPort,AbstractData> outputData){
  checkNotNull(workflowContext,"String_Node_Str");
  checkNotNull(step,"String_Node_Str");
  this.workflowContext=workflowContext;
  this.step=step;
  for (  Map.Entry<InputPort,Data> e : inputData.entrySet()) {
    this.inputData.put(e.getKey().getName(),e.getValue());
  }
  for (  Map.Entry<OutputPort,AbstractData> e : outputData.entrySet()) {
    this.outputData.put(e.getKey().getName(),e.getValue());
  }
}

Fixed version (ground truth):
/** 
 * Constructor.
 * @param step step related to the context
 */
WorkflowStepContext(final WorkflowContext workflowContext,final AbstractWorkflowStep step,Map<InputPort,Data> inputData,Map<OutputPort,AbstractData> outputData){
  checkNotNull(workflowContext,"String_Node_Str");
  checkNotNull(step,"String_Node_Str");
synchronized (this.getClass()) {
    this.id=(++instanceCounter);
  }
  this.contextName="String_Node_Str" + id;
  this.workflowContext=workflowContext;
  this.step=step;
  for (  Map.Entry<InputPort,Data> e : inputData.entrySet()) {
    this.inputData.put(e.getKey().getName(),e.getValue());
  }
  for (  Map.Entry<OutputPort,AbstractData> e : outputData.entrySet()) {
    this.outputData.put(e.getKey().getName(),e.getValue());
  }
}
Program: 141182
Project: 141182
Buggy source:
@Override public void run(){
  do {
    try {
      Thread.sleep(CHECKING_DELAY_MS);
    }
 catch (    InterruptedException e) {
      EoulsanLogger.getLogger().severe(e.getMessage());
    }
    if (this.step.getState() != READY) {
      continue;
    }
    final Set<WorkflowStepContext> contexts;
synchronized (this) {
      final WorkflowContext workflowContext=this.step.getAbstractWorkflow().getWorkflowContext();
      if (this.inputPorts.size() > 0) {
        contexts=createContexts(workflowContext);
      }
 else {
        contexts=createContextWhenNoInputPortExist(workflowContext);
      }
    }
    this.executors.processContexts(contexts);
    if (isNoTokenToReceive()) {
      this.executors.waitEndOfThreads();
      this.executors.getStepResult().setImmutable();
      if (this.step.isCreateLogFiles()) {
        writeStepResult();
      }
      if (this.executors.getStepResult().isSuccess()) {
        this.step.setState(DONE);
      }
 else {
        this.step.setState(FAIL);
      }
      sendEndOfStepTokens();
      this.endOfStep=true;
    }
  }
 while (!this.endOfStep);
  this.executors.stop();
}

Fixed version (ground truth):
@Override public void run(){
  do {
    try {
      Thread.sleep(CHECKING_DELAY_MS);
    }
 catch (    InterruptedException e) {
      EoulsanLogger.getLogger().severe(e.getMessage());
    }
    final StepState state=this.step.getState();
    if (!(state == READY || state == WORKING)) {
      continue;
    }
    if (state == READY) {
      this.step.setState(WORKING);
    }
    final Set<WorkflowStepContext> contexts;
synchronized (this) {
      final WorkflowContext workflowContext=this.step.getAbstractWorkflow().getWorkflowContext();
      if (this.inputPorts.size() > 0) {
        contexts=createContexts(workflowContext);
      }
 else {
        contexts=createContextWhenNoInputPortExist(workflowContext);
      }
    }
    this.executors.processContexts(contexts);
    if (isNoTokenToReceive()) {
      this.executors.waitEndOfThreads();
      this.executors.getStepResult().setImmutable();
      if (this.step.isCreateLogFiles()) {
        writeStepResult();
      }
      if (this.executors.getStepResult().isSuccess()) {
        this.step.setState(DONE);
      }
 else {
        this.step.setState(FAIL);
      }
      sendEndOfStepTokens();
      this.endOfStep=true;
    }
  }
 while (!this.endOfStep);
  this.executors.stop();
}
Program: 141183
Project: 141183
Buggy source:
/** 
 * Get the number of context created by the token manager.
 * @return the number of context created by the token manager
 */
public int getContextCount(){
  return this.cartesianProductsUsed.size();
}

Fixed version (ground truth):
/** 
 * Get the number of context created by the token manager.
 * @return the number of context created by the token manager
 */
public int getContextCount(){
  return this.inputPorts.size() == 0 ? 1 : this.cartesianProductsUsed.size();
}
Program: 141184
Project: 141184
Buggy source:
/** 
 * Set the state of the step.
 * @param state the new state of the step
 */
public void setState(final StepState state){
  if (state == null)   return;
  if (this.step.getType() == WorkflowStep.StepType.ROOT_STEP && state == StepState.WAITING)   this.stepState=StepState.READY;
 else   this.stepState=state;
  if (this.stepState == StepState.DONE)   for (  AbstractWorkflowStep step : this.stepsToInform)   step.getStepStateObserver().updateStatus();
  step.getAbstractWorkflow().updateStepState(this.step);
  for (  WorkflowStepObserver o : WorkflowStepObserverRegistry.getInstance().getObservers())   o.notifyStepState(this.step);
}

Fixed version (ground truth):
/** 
 * Set the state of the step.
 * @param state the new state of the step
 */
public void setState(final StepState state){
  if (state == null)   return;
synchronized (this) {
    if (this.step.getType() == WorkflowStep.StepType.ROOT_STEP && state == StepState.WAITING)     this.stepState=StepState.READY;
 else     this.stepState=state;
  }
  if (this.stepState == StepState.DONE)   for (  AbstractWorkflowStep step : this.stepsToInform)   step.getStepStateObserver().updateStatus();
  step.getAbstractWorkflow().updateStepState(this.step);
  for (  WorkflowStepObserver o : WorkflowStepObserverRegistry.getInstance().getObservers())   o.notifyStepState(this.step);
}
Program: 141185
Project: 141185
Buggy source:
public HadoopExecutorArguments(final long millisSinceEpoch,final Path designPath,final Path paramPath){
  super(millisSinceEpoch);
  setHadoopWorkingPathname(designPath.getParent().toString());
  final Path logPath=new Path(designPath.getParent().toString() + "String_Node_Str" + getJobId());
  final Path outputPath=new Path(designPath.getParent().toString() + "String_Node_Str" + getJobId());
  setLogPathname(logPath.toString());
  setOutputPathname(outputPath.toString());
  setDesignPathname(designPath.toString());
  setWorkflowPathname(paramPath.toString());
}

Fixed version (ground truth):
public HadoopExecutorArguments(final long millisSinceEpoch,final Path paramPath,final Path designPath,final Path destPath){
  super(millisSinceEpoch);
  setHadoopWorkingPathname(designPath.getParent().toString());
  final Path logPath=new Path(designPath.getParent().toString() + "String_Node_Str" + getJobId());
  final Path outputPath=new Path(designPath.getParent().toString() + "String_Node_Str" + getJobId());
  setLogPathname(logPath.toString());
  setOutputPathname(outputPath.toString());
  setDesignPathname(designPath.toString());
  setWorkflowPathname(paramPath.toString());
  setLocalWorkingPathname(new File("String_Node_Str").getAbsolutePath());
  setHadoopWorkingPathname(destPath.toString());
}
Program: 141187
Project: 141187
Buggy source:
@Override public void run(){
  resultWrapper.add(step.execute());
  System.out.println("String_Node_Str");
}

Fixed version (ground truth):
@Override public void run(){
  resultWrapper.add(step.execute());
}
Program: 141188
Project: 141188
Buggy source:
/** 
 * Launch the step and create a log file for each step.
 * @param step step
 * @return the step result object
 * @throws EoulsanException if an Interrupted exception occurs
 */
private StepResult executeStep(final AbstractWorkflowStep step) throws EoulsanException {
  final String threadGroupName="String_Node_Str" + step.getNumber();
  final ThreadGroup threadGroup=new ThreadGroup(threadGroupName);
  final Logger logger=step.isCreateLogFiles() ? createStepLogger(step,threadGroupName) : null;
  if (logger != null)   EoulsanLogger.registerThreadGroupLogger(threadGroup,logger);
  final List<StepResult> resultWrapper=Lists.newArrayList();
  final Runnable r=new Runnable(){
    @Override public void run(){
      resultWrapper.add(step.execute());
      System.out.println("String_Node_Str");
    }
  }
;
  try {
    final Thread thread=new Thread(threadGroup,r);
    thread.start();
    System.out.println("String_Node_Str");
    thread.join();
    System.out.println("String_Node_Str");
  }
 catch (  InterruptedException e) {
    throw new EoulsanException(e.getMessage());
  }
 finally {
    if (logger != null) {
      Handler handler=logger.getHandlers()[0];
      handler.close();
      EoulsanLogger.removeThreadGroupLogger(threadGroup);
      logger.removeHandler(handler);
    }
  }
  return resultWrapper.get(0);
}

Fixed version (ground truth):
/** 
 * Launch the step and create a log file for each step.
 * @param step step
 * @return the step result object
 * @throws EoulsanException if an Interrupted exception occurs
 */
private StepResult executeStep(final AbstractWorkflowStep step) throws EoulsanException {
  final String threadGroupName="String_Node_Str" + step.getNumber();
  final ThreadGroup threadGroup=new ThreadGroup(threadGroupName);
  final Logger logger=step.isCreateLogFiles() ? createStepLogger(step,threadGroupName) : null;
  if (logger != null)   EoulsanLogger.registerThreadGroupLogger(threadGroup,logger);
  final List<StepResult> resultWrapper=Lists.newArrayList();
  final Runnable r=new Runnable(){
    @Override public void run(){
      resultWrapper.add(step.execute());
    }
  }
;
  try {
    final Thread thread=new Thread(threadGroup,r);
    thread.start();
    thread.join();
  }
 catch (  InterruptedException e) {
    throw new EoulsanException(e.getMessage());
  }
 finally {
    if (logger != null) {
      Handler handler=logger.getHandlers()[0];
      handler.close();
      EoulsanLogger.removeThreadGroupLogger(threadGroup);
      logger.removeHandler(handler);
    }
  }
  return resultWrapper.get(0);
}
Program: 141189
Project: 141189
Buggy source:
/** 
 * Add a dependency for this step.
 * @param step the dependency
 */
protected void addDependency(final AbstractWorkflowStep step){
  Preconditions.checkNotNull(step,"String_Node_Str");
  if (this.getWorkflow() != step.getWorkflow())   throw new EoulsanRuntimeException("String_Node_Str");
  this.requieredSteps.add(step);
  step.stepsToInform.add(this);
}

Fixed version (ground truth):
/** 
 * Add a dependency for this step.
 * @param step the dependency
 */
protected void addDependency(final AbstractWorkflowStep step){
  checkNotNull(step,"String_Node_Str");
  if (step == this)   throw new EoulsanRuntimeException("String_Node_Str" + step.getId());
  if (this.getWorkflow() != step.getWorkflow())   throw new EoulsanRuntimeException("String_Node_Str");
  this.requieredSteps.add(step);
  step.stepsToInform.add(this);
}
Program: 141190
Project: 141190
Buggy source:
/** 
 * Get the file count for an input step of the step.
 * @param portName name of the output port that generate file
 * @param sample sample sample that correspond to the file
 * @param existingFiles if true return the number of files that really existsotherwise the maximum of files.
 * @return the count of intput DataFiles
 */
int getInputDataFileCount(final String portName,final Sample sample,final boolean existingFiles){
  Preconditions.checkNotNull(portName,"String_Node_Str");
  Preconditions.checkNotNull(sample,"String_Node_Str");
  if (!getInputPorts().contains(portName))   throw new EoulsanRuntimeException("String_Node_Str" + portName);
  final WorkflowInputPort port=getInputPorts().getPort(portName);
  if (!port.isLinked())   throw new EoulsanRuntimeException("String_Node_Str" + portName + "String_Node_Str"+ getId()+ "String_Node_Str");
  return port.getLink().getDataFileCount(sample,existingFiles);
}

Fixed version (ground truth):
/** 
 * Get the file count for an input step of the step.
 * @param portName name of the output port that generate file
 * @param sample sample sample that correspond to the file
 * @param existingFiles if true return the number of files that really existsotherwise the maximum of files.
 * @return the count of intput DataFiles
 */
int getInputDataFileCount(final String portName,final Sample sample,final boolean existingFiles){
  checkNotNull(portName,"String_Node_Str");
  checkNotNull(sample,"String_Node_Str");
  if (!getInputPorts().contains(portName))   throw new EoulsanRuntimeException("String_Node_Str" + portName);
  final WorkflowInputPort port=getInputPorts().getPort(portName);
  if (!port.isLinked())   throw new EoulsanRuntimeException("String_Node_Str" + portName + "String_Node_Str"+ getId()+ "String_Node_Str");
  return port.getLink().getDataFileCount(sample,existingFiles);
}
Program: 141191
Project: 141191
Buggy source:
/** 
 * Initialization Eoulsan runtime for external application who needed Eoulsan
 * @throws IOException
 * @throws EoulsanException
 */
public static void initEoulsanRuntimeForExternalApp() throws IOException, EoulsanException {
  if (!EoulsanRuntime.isRuntime())   newEoulsanRuntime(new Settings(true));
  Logger.getLogger(Globals.APP_NAME).setLevel(Level.OFF);
}

Fixed version (ground truth):
/** 
 * Initialization Eoulsan runtime for external application who needed Eoulsan
 * @throws IOException
 * @throws EoulsanException
 */
public static void initEoulsanRuntimeForExternalApp() throws IOException, EoulsanException {
  if (!EoulsanRuntime.isRuntime())   newEoulsanRuntime(new Settings(true));
  final Handler[] handlers=EoulsanLogger.getLogger().getHandlers();
  if (handlers != null)   for (  Handler handler : handlers)   handler.setLevel(Level.OFF);
}
Program: 141192
Project: 141192
Buggy source:
@Override public void run(){
  if (parserLine != null) {
    try {
      InputStream is=p.getInputStream();
      BufferedReader buff=new BufferedReader(new InputStreamReader(is));
      String line="String_Node_Str";
      while ((line=buff.readLine()) != null) {
        parserLine.parseLine(line);
      }
      buff.close();
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  if (parserLine != null) {
    try {
      InputStream is=p.getInputStream();
      BufferedReader buff=new BufferedReader(new InputStreamReader(is,"String_Node_Str"));
      String line="String_Node_Str";
      while ((line=buff.readLine()) != null) {
        parserLine.parseLine(line);
      }
      buff.close();
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
}
Program: 141195
Project: 141195
Buggy source:
/** 
 * Run checker (runs only for Design step).
 * @param status step status
 * @return a StepResult object
 */
private void configureCheckerStep(final StepStatus status){
  if (getType() != CHECKER_STEP)   return;
  final CheckerStep checkerStep=(CheckerStep)StepInstances.getInstance().getStep(this);
  final Set<WorkflowStepOutputDataFile> files=getWorkflow().getWorkflowFilesAtRootStep().getInputFiles();
  final Design design=this.getWorkflow().getDesign();
  if (design.getSampleCount() == 0)   return;
  for (  WorkflowStepOutputDataFile file : files)   if (file.getFormat().isChecker()) {
    checkerStep.addChecker(file.getFormat().getChecker());
  }
}

Fixed version (ground truth):
/** 
 * Run checker (runs only for Design step).
 * @param status step status
 */
private void configureCheckerStep(final StepStatus status){
  if (getType() != CHECKER_STEP)   return;
  final CheckerStep checkerStep=(CheckerStep)StepInstances.getInstance().getStep(this);
  final Set<WorkflowStepOutputDataFile> files=getWorkflow().getWorkflowFilesAtRootStep().getInputFiles();
  final Design design=this.getWorkflow().getDesign();
  if (design.getSampleCount() == 0)   return;
  for (  WorkflowStepOutputDataFile file : files)   if (file.getFormat().isChecker()) {
    checkerStep.addChecker(file.getFormat().getChecker());
  }
}
Program: 141196
Project: 141196
Buggy source:
/** 
 * Define the working directory of the step.
 * @param workflow the workflow
 * @param step step instance
 * @return the working directory of the step
 */
private static final DataFile defineWorkingDirectory(final AbstractWorkflow workflow,final Step step,final boolean copyResultsToOutput){
  final boolean hadoopMode=EoulsanRuntime.getRuntime().isHadoopMode();
  if (!hadoopMode) {
    if (copyResultsToOutput)     return workflow.getOutputDir();
 else     return workflow.getLocalWorkingDir();
  }
switch (EoulsanMode.getEoulsanMode(step.getClass())) {
case HADOOP_COMPATIBLE:
    if (copyResultsToOutput)     return workflow.getOutputDir();
 else     return workflow.getHadoopWorkingDir();
case HADOOP_ONLY:
  return workflow.getHadoopWorkingDir();
default :
return workflow.getLocalWorkingDir();
}
}

Fixed version (ground truth):
/** 
 * Define the working directory of the step.
 * @param workflow the workflow
 * @param step step instance
 * @return the working directory of the step
 */
private static final DataFile defineWorkingDirectory(final AbstractWorkflow workflow,final Step step,final boolean copyResultsToOutput){
  final boolean hadoopMode=EoulsanRuntime.getRuntime().isHadoopMode();
  if (!hadoopMode) {
    if (copyResultsToOutput)     return workflow.getOutputDir();
    return workflow.getLocalWorkingDir();
  }
switch (EoulsanMode.getEoulsanMode(step.getClass())) {
case HADOOP_COMPATIBLE:
    if (copyResultsToOutput)     return workflow.getOutputDir();
  return workflow.getHadoopWorkingDir();
case HADOOP_ONLY:
return workflow.getHadoopWorkingDir();
default :
return workflow.getLocalWorkingDir();
}
}
Program: 141200
Project: 141200
Buggy source:
/** 
 * Create a new step that copy output data of a step.
 * @param workflow workflow where adding the step
 * @param oriStepId id of the step that required copying data
 * @param format format of the data
 * @return a new step
 * @throws EoulsanException if an error occurs while creating the step
 */
private static CommandWorkflowStep newOutputFormatCopyStep(final CommandWorkflow workflow,final String oriStepId,final DataFile workingDirectory,final Set<DataFormat> formats) throws EoulsanException {
  final String stepName=CopyOutputFormatStep.STEP_NAME;
  final Set<String> stepsIds=Sets.newHashSet();
  for (  WorkflowStep s : workflow.getSteps())   stepsIds.add(s.getId());
  int i=1;
  String stepId;
  do {
    stepId=oriStepId + "String_Node_Str" + i;
    i++;
  }
 while (stepsIds.contains(stepId));
  List<String> formatsList=Lists.newArrayList();
  for (  DataFormat format : formats)   formatsList.add(format.getName());
  final Set<Parameter> parameters=Sets.newHashSet();
  parameters.add(new Parameter(CopyOutputFormatStep.FORMAT_PARAMETER,Joiner.on(',').join(formatsList)));
  CommandWorkflowStep step=new CommandWorkflowStep(workflow,stepId,stepName,parameters,false,false);
  step.configure();
  return step;
}

Fixed version (ground truth):
/** 
 * Create a new step that copy output data of a step.
 * @param workflow workflow where adding the step
 * @param oriStepId id of the step that required copying data
 * @param format format of the data
 * @return a new step
 * @throws EoulsanException if an error occurs while creating the step
 */
private static CommandWorkflowStep newOutputFormatCopyStep(final CommandWorkflow workflow,final String oriStepId,final Set<DataFormat> formats) throws EoulsanException {
  final String stepName=CopyOutputFormatStep.STEP_NAME;
  final Set<String> stepsIds=Sets.newHashSet();
  for (  WorkflowStep s : workflow.getSteps())   stepsIds.add(s.getId());
  int i=1;
  String stepId;
  do {
    stepId=oriStepId + "String_Node_Str" + i;
    i++;
  }
 while (stepsIds.contains(stepId));
  List<String> formatsList=Lists.newArrayList();
  for (  DataFormat format : formats)   formatsList.add(format.getName());
  final Set<Parameter> parameters=Sets.newHashSet();
  parameters.add(new Parameter(CopyOutputFormatStep.FORMAT_PARAMETER,Joiner.on(',').join(formatsList)));
  CommandWorkflowStep step=new CommandWorkflowStep(workflow,stepId,stepName,parameters,false,false);
  step.configure();
  return step;
}
Program: 141201
Project: 141201
Buggy source:
/** 
 * Get a step instance.
 * @param workflowStep workflow step
 * @return a step instance
 * @throws EoulsanException if an error occurs while loading the step
 */
public Step getStep(final WorkflowStep workflowStep,final String stepName) throws EoulsanException {
  checkNotNull(stepName,"String_Node_Str");
  if (!this.steps.containsKey(workflowStep)) {
    final Step stepInstance=loadStep(stepName);
    if (stepInstance == null)     return null;
    registerStep(workflowStep,stepInstance);
    return stepInstance;
  }
  return this.steps.get(workflowStep);
}

Fixed version (ground truth):
/** 
 * Get a step instance.
 * @param workflowStep workflow step
 * @return a step instance
 * @throws EoulsanException if an error occurs while loading the step
 */
public Step getStep(final WorkflowStep workflowStep,final String stepName) throws EoulsanException {
  checkNotNull(stepName,"String_Node_Str");
  if (!this.steps.containsKey(workflowStep)) {
    final Step stepInstance=loadStep(stepName);
    registerStep(workflowStep,stepInstance);
    return stepInstance;
  }
  return this.steps.get(workflowStep);
}
Program: 141202
Project: 141202
Buggy source:
@Override public void updateStepState(final WorkflowStep step,final String note){
  if (step == null)   return;
  if (this.lastStates.containsKey(step) && this.lastNotes.containsKey(step) && step.getState() == this.lastStates.get(step) && note == this.lastNotes.get(step))   return;
  for (  WorkflowStepEvent listener : this.listeners)   listener.updateStepState(step,note);
  this.lastStates.put(step,step.getState());
  this.lastNotes.put(step,note);
}

Fixed version (ground truth):
@Override public void updateStepState(final WorkflowStep step,final String note){
  if (step == null)   return;
  if (this.lastStates.containsKey(step) && this.lastNotes.containsKey(step) && step.getState() == this.lastStates.get(step) && Objects.equal(note,this.lastNotes.get(step)))   return;
  for (  WorkflowStepEvent listener : this.listeners)   listener.updateStepState(step,note);
  this.lastStates.put(step,step.getState());
  this.lastNotes.put(step,note);
}
Program: 141203
Project: 141203
Buggy source:
/** 
 * Get the DataFormat of a file from its filename
 * @param filename the filename of the file
 * @return a DataFormat or null if the DataFormat was not found
 */
public DataFormat getDataFormatFromFilename(final String filename){
  if (filename == null)   throw new NullPointerException("String_Node_Str");
  final String f=StringUtils.filenameWithoutCompressionExtension(filename.trim());
  final int dotPos=f.lastIndexOf('.');
  if (dotPos == -1)   return null;
  final String ext=f.substring(dotPos);
  final int underscorePos=f.lastIndexOf('_',dotPos);
  if (underscorePos != -1) {
    final String prefix=f.substring(0,underscorePos + 1);
    final DataFormat df=getDataFormatFromFilename(prefix,ext);
    if (df != null)     return df;
  }
  for (  DataFormat df : this.formats)   if (df.isDataTypeFromDesignFile())   for (  String dfExt : df.getExtensions())   if (dfExt.equals(ext))   return df;
  return null;
}

Fixed version (ground truth):
/** 
 * Get the DataFormat of a file from its filename
 * @param filename the filename of the file
 * @return a DataFormat or null if the DataFormat was not found
 */
public DataFormat getDataFormatFromFilename(final String filename){
  if (filename == null)   throw new NullPointerException("String_Node_Str");
  final String f=StringUtils.filenameWithoutCompressionExtension(filename.trim());
  final int dotPos=f.lastIndexOf('.');
  if (dotPos == -1)   return null;
  final String ext=f.substring(dotPos);
  final int underscorePos=f.lastIndexOf('_',dotPos);
  if (underscorePos != -1) {
    final String prefix=f.substring(0,underscorePos + 1);
    final DataFormat df=getDataFormatFromFilename(prefix,ext);
    if (df != null)     return df;
  }
  for (  DataFormat df : this.formats)   if (df.isDataFormatFromDesignFile())   for (  String dfExt : df.getExtensions())   if (dfExt.equals(ext))   return df;
  return null;
}
Program: 141205
Project: 141205
Buggy source:
private final boolean isValidLineAndSaveSAMHeader(final String line,final Context context) throws IOException {
  if (line.length() == 0)   return false;
  if (line.charAt(0) != '@') {
    if (this.headers != null) {
      final Path outputPath=new Path(context.getConfiguration().get("String_Node_Str"));
      final Path headerPath=new Path(outputPath,SAM_HEADER_FILE_PREFIX + context.getTaskAttemptID().toString());
      final Writer writer=new OutputStreamWriter(PathUtils.createOutputStream(headerPath,context.getConfiguration()));
      for (      String l : this.headers)       writer.write(l + "String_Node_Str");
      writer.close();
      this.headers=null;
    }
    return true;
  }
  if (this.headers == null)   this.headers=Lists.newArrayList();
  this.headers.add(line);
  return false;
}

Fixed version (ground truth):
private final boolean isValidLineAndSaveSAMHeader(final String line,final Context context) throws IOException {
  if (line.length() == 0)   return false;
  if (line.charAt(0) != '@') {
    if (this.headers != null) {
      final Path outputPath=new Path(context.getConfiguration().get("String_Node_Str"));
      final Path headerPath=new Path(outputPath,SAM_HEADER_FILE_PREFIX + context.getTaskAttemptID().toString());
      final Writer writer=new OutputStreamWriter(PathUtils.createOutputStream(headerPath,context.getConfiguration()),"String_Node_Str");
      for (      String l : this.headers)       writer.write(l + "String_Node_Str");
      writer.close();
      this.headers=null;
    }
    return true;
  }
  if (this.headers == null)   this.headers=Lists.newArrayList();
  this.headers.add(line);
  return false;
}
Program: 141207
Project: 141207
Buggy source:
/** 
 * Test if two stream are equals
 * @param fileA First filename to compare
 * @param fileB Second filename to compare
 * @return true if the two stream are equals
 * @throws IOException if an error occurs while reading the streams
 */
public static boolean compareFile(final File fileA,final File fileB) throws IOException {
  final InputStream isa=new FileInputStream(fileA);
  final InputStream isb=new FileInputStream(fileB);
  try {
    return compareFile(isa,isb);
  }
 catch (  IOException e) {
    throw e;
  }
 finally {
    isa.close();
    isb.close();
  }
}

Fixed version (ground truth):
/** 
 * Test if two stream are equals
 * @param fileA First filename to compare
 * @param fileB Second filename to compare
 * @return true if the two stream are equals
 * @throws IOException if an error occurs while reading the streams
 */
public static boolean compareFile(final File fileA,final File fileB) throws IOException {
  InputStream isa=null;
  InputStream isb=null;
  try {
    isa=new FileInputStream(fileA);
    isb=new FileInputStream(fileB);
    return compareFile(isa,isb);
  }
 catch (  IOException e) {
    throw e;
  }
 finally {
    if (isa != null)     isa.close();
    if (isb != null)     isb.close();
  }
}
Program: 141208
Project: 141208
Buggy source:
@Override public void filterReadAlignments(final List<SAMRecord> records){
  if (records == null || records.isEmpty())   return;
  if (!records.get(0).getReadPairedFlag()) {
    if (records.size() > 1)     records.removeAll(records);
  }
 else {
    if (records.size() > 2)     records.removeAll(records);
  }
}

Fixed version (ground truth):
@Override public void filterReadAlignments(final List<SAMRecord> records){
  if (records == null || records.isEmpty())   return;
  if (!records.get(0).getReadPairedFlag()) {
    if (records.size() > 1)     records.clear();
  }
 else {
    if (records.size() > 2)     records.clear();
  }
}
Program: 141210
Project: 141210
Buggy source:
@Override public void run(){
  if (parserLine != null) {
    try {
      InputStream is=p.getInputStream();
      BufferedReader buff=new BufferedReader(new InputStreamReader(is));
      String line="String_Node_Str";
      while ((line=buff.readLine()) != null) {
        parserLine.parseLine(line);
      }
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  if (parserLine != null) {
    try {
      InputStream is=p.getInputStream();
      BufferedReader buff=new BufferedReader(new InputStreamReader(is));
      String line="String_Node_Str";
      while ((line=buff.readLine()) != null) {
        parserLine.parseLine(line);
      }
      buff.close();
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
}
Program: 141212
Project: 141212
Buggy source:
@Override protected void internalMap(final File readsFile,final File archiveIndex,final SAMParserLine parserLine) throws IOException {
  new UnsupportedOperationException();
}

Fixed version (ground truth):
@Override protected void internalMap(final File readsFile,final File archiveIndex,final SAMParserLine parserLine) throws IOException {
  throw new UnsupportedOperationException();
}
Program: 141213
Project: 141213
Buggy source:
@Override protected void internalMap(final File readsFile,final File archiveIndex,final SAMParserLine parserLine) throws IOException {
  new UnsupportedOperationException();
}

Fixed version (ground truth):
@Override protected void internalMap(final File readsFile,final File archiveIndex,final SAMParserLine parserLine) throws IOException {
  throw new UnsupportedOperationException();
}
Program: 141214
Project: 141214
Buggy source:
@Override protected void internalMap(final File readsFile,final File archiveIndex,final SAMParserLine parserLine) throws IOException {
  new UnsupportedOperationException();
}

Fixed version (ground truth):
@Override protected void internalMap(final File readsFile,final File archiveIndex,final SAMParserLine parserLine) throws IOException {
  throw new UnsupportedOperationException();
}
Program: 141215
Project: 141215
Buggy source:
@Override protected void internalMap(final File readsFile,final File archiveIndex,final SAMParserLine parserLine) throws IOException {
  new UnsupportedOperationException();
}

Fixed version (ground truth):
@Override protected void internalMap(final File readsFile,final File archiveIndex,final SAMParserLine parserLine) throws IOException {
  throw new UnsupportedOperationException();
}
Program: 141216
Project: 141216
Buggy source:
/** 
 * Get the real Context object. This method is useful to redefine context values like base directory.
 * @return The Context object
 */
WorkflowContext getWorkflowContext(){
  return this.workflowContext;
}

Fixed version (ground truth):
/** 
 * Get the real Context object. This method is useful to redefine context values like base directory.
 * @return The Context object
 */
public WorkflowContext getWorkflowContext(){
  return this.workflowContext;
}
Program: 141217
Project: 141217
Buggy source:
/** 
 * Execute the step.
 * @return a StepResult object
 */
StepResult execute(){
  if (getState() != StepState.READY)   throw new IllegalStateException("String_Node_Str" + getState());
  getLogger().info("String_Node_Str" + getId() + "String_Node_Str");
  setState(StepState.WORKING);
  final StepStatus status=new WorkflowStepStatus(this);
  final StepResult result;
switch (getType()) {
case CHECKER_STEP:
    configureCheckerStep(status);
case STANDARD_STEP:
case GENERATOR_STEP:
  final Step step=StepInstances.getInstance().getStep(this);
result=step.execute(this.workflow.getDesign(),getContext(),status);
break;
default :
result=null;
}
if (result != null) getLogger().info("String_Node_Str" + getId() + "String_Node_Str"+ StringUtils.toTimeHumanReadable(result.getDuration())+ "String_Node_Str");
setState(StepState.DONE);
return result;
}

Fixed version (ground truth):
/** 
 * Execute the step.
 * @return a StepResult object
 */
StepResult execute(){
  if (getState() != StepState.READY)   throw new IllegalStateException("String_Node_Str" + getState());
  getLogger().info("String_Node_Str" + getId() + "String_Node_Str");
  setState(StepState.WORKING);
  final StepStatus status=new WorkflowStepStatus(this);
  final StepResult result;
switch (getType()) {
case CHECKER_STEP:
    configureCheckerStep(status);
case STANDARD_STEP:
case GENERATOR_STEP:
  final Step step=StepInstances.getInstance().getStep(this);
result=step.execute(this.workflow.getDesign(),getContext(),status);
break;
default :
result=null;
}
if (result != null) getLogger().info("String_Node_Str" + getId() + "String_Node_Str"+ StringUtils.toTimeHumanReadable(result.getDuration())+ "String_Node_Str");
setState(StepState.DONE);
this.result=result;
return result;
}
Program: 141219
Project: 141219
Buggy source:
/** 
 * Set the start date.
 * @param date the start date
 */
public void setStartTime(final Date date){
  checkNotNull(date,"String_Node_Str");
  this.startTime=date;
}

Fixed version (ground truth):
/** 
 * Set the start date.
 * @param date the start date
 */
public void setStartTime(final Date date){
  checkNotNull(date,"String_Node_Str");
  this.startTime=new Date(date.getTime());
}
Program: 141220
Project: 141220
Buggy source:
/** 
 * Set the end date.
 * @param date the end date
 */
public void setEndTime(final Date date){
  checkNotNull(date,"String_Node_Str");
  this.endTime=date;
}

Fixed version (ground truth):
/** 
 * Set the end date.
 * @param date the end date
 */
public void setEndTime(final Date date){
  checkNotNull(date,"String_Node_Str");
  this.endTime=new Date(date.getTime());
}
Program: 141221
Project: 141221
Buggy source:
@Override public Map<String,Long> getSampleCounters(final Sample sample){
  return this.getSampleCounters(sample);
}

Fixed version (ground truth):
@Override public Map<String,Long> getSampleCounters(final Sample sample){
  return this.result.getSampleCounters(sample);
}
Program: 141222
Project: 141222
Buggy source:
@Override public int hashCode(){
  final String[] extensions=getExtensions();
  final Integer extensionsHashCode=extensions == null ? null : extensions.hashCode();
  final Integer generatorHashCode=isGenerator() ? getGenerator().getClass().hashCode() : null;
  final Integer checkerHashCode=isChecker() ? getChecker().getClass().hashCode() : null;
  return Objects.hashCode(getName(),getDescription(),getContentType(),getDefaultExtention(),extensionsHashCode,isGenerator(),isChecker(),generatorHashCode,checkerHashCode,getMaxFilesCount());
}

Fixed version (ground truth):
@Override public int hashCode(){
  final String[] extensions=getExtensions();
  final Integer extensionsHashCode=extensions == null ? null : Arrays.hashCode(extensions);
  final Integer generatorHashCode=isGenerator() ? getGenerator().getClass().hashCode() : null;
  final Integer checkerHashCode=isChecker() ? getChecker().getClass().hashCode() : null;
  return Objects.hashCode(getName(),getDescription(),getContentType(),getDefaultExtention(),extensionsHashCode,isGenerator(),isChecker(),generatorHashCode,checkerHashCode,getMaxFilesCount());
}