nus-yam/ex-repair huggingface dataset:
Program: 73674
Project: 73674
Buggy source:
/** 
 * Test the migrateModels() method in the case when the given path is correct and it contains models at the first level and models inside a directory which is inside the current directory.
 * @exception Exception Thrown by PowerMock if error occurs in the testing.
 */
@Test public void testMigrateModelsDepth() throws Exception {
  String directoryPath=createDirectory(2,2);
  MigrateModelsManager migrateModelsManager=new MigrateModelsManager();
  try {
    String csvFilePath=migrateModelsManager.migrateModels(directoryPath);
    assertTrue(csvFilePath.equals(directoryPath + "String_Node_Str"));
  }
 catch (  Exception e) {
    fail("String_Node_Str" + e.getMessage());
  }
 finally {
    deleteDirectory(directoryPath);
  }
}

Fixed version (ground truth):
/** 
 * Test the migrateModels() method in the case when the given path is correct and it contains models at the first level and models inside a directory which is inside the current directory.
 * @exception Exception Thrown by PowerMock if error occurs in the testing.
 */
@Test public void testMigrateModelsDepth() throws Exception {
  String directoryPath=createDirectory(2,2);
  MigrateModelsManager migrateModelsManager=new MigrateModelsManager();
  try {
    String csvFilePath=migrateModelsManager.migrateModels(directoryPath);
    assertTrue(csvFilePath.equals(directoryPath + "String_Node_Str"));
  }
 catch (  IOException e) {
    fail("String_Node_Str" + e.getMessage());
  }
 finally {
    deleteDirectory(directoryPath);
  }
}
Program: 73676
Project: 73676
Buggy source:
/** 
 * Migrate models from the file system stored in the given path to the database.
 * @param directoryPath The path on the file system where the models exist.
 * @return A string representing the path to the CSV file the contains the results of the migration.
 * @exception IOException Thrown if there is an error reading or writing files.
 */
public String migrateModels(String directoryPath) throws IOException {
  File directoryFile=new File(directoryPath);
  if (directoryFile.exists() == false) {
    throw new IOException("String_Node_Str" + directoryPath + "String_Node_Str");
  }
  String csvFilePath=directoryPath + System.getProperty("String_Node_Str") + "String_Node_Str";
  try {
    File csvFile=new File(csvFilePath);
    csvFile.createNewFile();
  }
 catch (  Exception e) {
    csvFilePath=StringUtilities.preferencesDirectory() + "String_Node_Str";
  }
  _csvFileWriter=new FileWriter(csvFilePath);
  _csvFileWriter.write("String_Node_Str" + System.getProperty("String_Node_Str"));
  try {
    _readFiles(directoryFile);
  }
  finally {
    _csvFileWriter.flush();
    _csvFileWriter.close();
  }
  return csvFilePath;
}

Fixed version (ground truth):
/** 
 * Migrate models from the file system stored in the given path to the database.
 * @param directoryPath The path on the file system where the models exist.
 * @return A string representing the path to the CSV file the contains the results of the migration.
 * @exception IOException Thrown if there is an error reading or writing files.
 */
public String migrateModels(String directoryPath) throws IOException {
  File directoryFile=new File(directoryPath);
  if (directoryFile.exists() == false) {
    throw new IOException("String_Node_Str" + directoryPath + "String_Node_Str");
  }
  String csvFilePath=directoryPath + System.getProperty("String_Node_Str") + "String_Node_Str";
  try {
    File csvFile=new File(csvFilePath);
    csvFile.createNewFile();
  }
 catch (  IOException e) {
    csvFilePath=StringUtilities.preferencesDirectory() + "String_Node_Str";
  }
  _csvFileWriter=new FileWriter(csvFilePath);
  _csvFileWriter.write("String_Node_Str" + System.getProperty("String_Node_Str"));
  try {
    _readFiles(directoryFile);
  }
  finally {
    _csvFileWriter.flush();
    _csvFileWriter.close();
  }
  return csvFilePath;
}
Program: 73677
Project: 73677
Buggy source:
/** 
 * Return the model name.
 * @see #setModelName
 */
public String getModelName(){
  return modelName;
}

Fixed version (ground truth):
/** 
 * Return the model name.
 * @return The model name.
 * @see #setModelName
 */
public String getModelName(){
  return modelName;
}
Program: 73679
Project: 73679
Buggy source:
/** 
 * Specifies the input array that will read the buffer allocated as output.  Here we only check that everything is correct, and computes addresses in output buffer.
 * @param port the associated port
 * @param actor the associated actor
 * @exception IllegalActionException
 */
public void setInputArray(IOPort port,Actor actor) throws IllegalActionException {
  if (_buffer != null) {
    fillParameters(actor,port);
  }
}

Fixed version (ground truth):
/** 
 * Specifies the input array that will read the buffer allocated as output.  Here we only check that everything is correct, and computes addresses in output buffer.
 * @param port the associated port
 * @param actor the associated actor
 * @exception IllegalActionException
 */
public void setInputArray(IOPort port,Actor actor) throws IllegalActionException {
  if (!_dynamic && _buffer != null) {
    fillParameters(actor,port);
  }
}
Program: 73681
Project: 73681
Buggy source:
/** 
 * Construct a Pthales scheduler in the given container with the given name.
 * @param container The container.
 * @param name The name of this attribute.
 * @exception IllegalActionException If the attribute is not of anacceptable class for the container, or if the name contains a period.
 * @exception NameDuplicationException If the name coincides withan attribute already in the container.
 */
public PthalesScheduler(Director container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
}

Fixed version (ground truth):
public PthalesScheduler(Director container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
}
Program: 73682
Project: 73682
Buggy source:
/** 
 * Generate fire code. The method reads in <code>fireBlock</code> from Accumulator.c, replaces macros with their values and returns the processed code block.
 * @return The generated code.
 * @exception IllegalActionException If the code stream encounters anerror in processing the specified code block(s).
 */
protected String _generateFireCode() throws IllegalActionException {
  super._generateFireCode();
  ptolemy.actor.lib.Accumulator actor=(ptolemy.actor.lib.Accumulator)getComponent();
  ArrayList args=new ArrayList<String>();
  args.add("String_Node_Str");
  Type type=actor.output.getType();
  String targetType=targetType(type);
  CodeStream codeStream=_templateParser.getCodeStream();
  if (actor.reset.isOutsideConnected()) {
    codeStream.appendCodeBlock("String_Node_Str");
    for (int i=1; i < actor.reset.getWidth(); i++) {
      args.set(0,Integer.valueOf(i).toString());
      codeStream.appendCodeBlock("String_Node_Str",args);
    }
    codeStream.appendCodeBlock("String_Node_Str");
    codeStream.appendCodeBlock((targetType.equals("String_Node_Str")) ? "String_Node_Str" : "String_Node_Str");
  }
  if (!getCodeGenerator().isPrimitive(type)) {
    targetType="String_Node_Str";
  }
  for (int i=0; i < actor.input.getWidth(); i++) {
    args.set(0,Integer.valueOf(i).toString());
    codeStream.appendCodeBlock(targetType + "String_Node_Str",args);
  }
  codeStream.appendCodeBlock("String_Node_Str");
  return processCode(codeStream.toString());
}

Fixed version (ground truth):
/** 
 * Generate fire code. The method reads in <code>fireBlock</code> from Accumulator.c, replaces macros with their values and returns the processed code block.
 * @return The generated code.
 * @exception IllegalActionException If the code stream encounters anerror in processing the specified code block(s).
 */
protected String _generateFireCode() throws IllegalActionException {
  super._generateFireCode();
  ptolemy.actor.lib.Accumulator actor=(ptolemy.actor.lib.Accumulator)getComponent();
  ArrayList args=new ArrayList<String>();
  args.add("String_Node_Str");
  Type type=actor.output.getType();
  String targetType=targetType(type);
  CodeStream codeStream=_templateParser.getCodeStream();
  if (actor.reset.isOutsideConnected()) {
    codeStream.appendCodeBlock("String_Node_Str");
    for (int i=1; i < actor.reset.getWidth(); i++) {
      args.set(0,Integer.valueOf(i).toString());
      codeStream.appendCodeBlock("String_Node_Str",args);
    }
    codeStream.appendCodeBlock("String_Node_Str");
    codeStream.appendCodeBlock((targetType.equals("String_Node_Str")) ? "String_Node_Str" : "String_Node_Str");
    codeStream.append("String_Node_Str");
  }
  if (!getCodeGenerator().isPrimitive(type)) {
    targetType="String_Node_Str";
  }
  for (int i=0; i < actor.input.getWidth(); i++) {
    args.set(0,Integer.valueOf(i).toString());
    codeStream.appendCodeBlock(targetType + "String_Node_Str",args);
  }
  codeStream.appendCodeBlock("String_Node_Str");
  return processCode(codeStream.toString());
}
Program: 73683
Project: 73683
Buggy source:
/** 
 * If this actor is opaque, invoke the prefire() method of the local director. This method returns true if the actor is ready to fire (determined by the prefire() method of the director). It is read-synchronized on the workspace.
 * @exception IllegalActionException If there is no director,or if the director's prefire() method throws it, or if this actor is not opaque.
 */
public boolean prefire() throws IllegalActionException {
  boolean result=super.prefire();
  Iterator<?> outports=outputPortList().iterator();
  while (outports.hasNext() && !_stopRequested) {
    IOPort p=(IOPort)outports.next();
    LinkedHashMap<String,Integer> sizes=PthalesIOPort.getArraySizes(p,_repetition);
    List<Token> header=new ArrayList<Token>();
    int nbDims=PthalesIOPort.getDimensions(p).length;
    header.add(new IntToken(nbDims));
    header.add(new IntToken(PthalesIOPort.getNbTokenPerData(p)));
    for (    String dim : sizes.keySet()) {
      header.add(new StringToken(dim));
      header.add(new IntToken(sizes.get(dim)));
    }
    for (int i=0; i < p.getWidth(); i++) {
      for (int j=0; j < header.size(); j++) {
        p.send(i,header.get(j));
      }
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * If this actor is opaque, invoke the prefire() method of the local director. This method returns true if the actor is ready to fire (determined by the prefire() method of the director). It is read-synchronized on the workspace.
 * @exception IllegalActionException If there is no director,or if the director's prefire() method throws it, or if this actor is not opaque.
 */
public boolean prefire() throws IllegalActionException {
  boolean result=super.prefire();
  if (!_headerSent) {
    Iterator<?> outports=outputPortList().iterator();
    while (outports.hasNext() && !_stopRequested) {
      IOPort p=(IOPort)outports.next();
      LinkedHashMap<String,Integer> sizes=PthalesIOPort.getArraySizes(p,_repetition);
      List<Token> header=new ArrayList<Token>();
      int nbDims=PthalesIOPort.getDimensions(p).length;
      header.add(new IntToken(nbDims));
      header.add(new IntToken(PthalesIOPort.getNbTokenPerData(p)));
      for (      String dim : sizes.keySet()) {
        header.add(new StringToken(dim));
        header.add(new IntToken(sizes.get(dim)));
      }
      for (int i=0; i < p.getWidth(); i++) {
        for (int j=0; j < header.size(); j++) {
          p.send(i,header.get(j));
        }
      }
    }
    _headerSent=true;
  }
  return result;
}
Program: 73684
Project: 73684
Buggy source:
/** 
 * Invoke a specified number of iterations of the actor. An iteration is equivalent to invoking prefire(), fire(), and postfire(), in that order. In an iteration, if prefire() returns true, then fire() will be called once, followed by postfire(). Otherwise, if prefire() returns false, fire() and postfire() are not invoked, and this method returns NOT_READY. If postfire() returns false, then no more iterations are invoked, and this method returns STOP_ITERATING. Otherwise, it returns COMPLETED.  If stop() is called during this iteration, then cease iterating and return STOP_ITERATING. <p> This base class method actually invokes prefire(), fire(), and postfire(), as described above, but a derived class may override the method to execute more efficient code.
 * @param count The number of iterations to perform.
 * @return NOT_READY, STOP_ITERATING, or COMPLETED.
 * @exception IllegalActionException If iterating is notpermitted, or if prefire(), fire(), or postfire() throw it.
 */
public int iterate(int count) throws IllegalActionException {
  int iterations=count;
  if (count == 0) {
    iterations=computeIterations();
  }
  return super.iterate(iterations);
}

Fixed version (ground truth):
/** 
 * Invoke a specified number of iterations of the actor. An iteration is equivalent to invoking prefire(), fire(), and postfire(), in that order. In an iteration, if prefire() returns true, then fire() will be called once, followed by postfire(). Otherwise, if prefire() returns false, fire() and postfire() are not invoked, and this method returns NOT_READY. If postfire() returns false, then no more iterations are invoked, and this method returns STOP_ITERATING. Otherwise, it returns COMPLETED.  If stop() is called during this iteration, then cease iterating and return STOP_ITERATING. <p> This base class method actually invokes prefire(), fire(), and postfire(), as described above, but a derived class may override the method to execute more efficient code.
 * @param count The number of iterations to perform.
 * @return NOT_READY, STOP_ITERATING, or COMPLETED.
 * @exception IllegalActionException If iterating is notpermitted, or if prefire(), fire(), or postfire() throw it.
 */
public int iterate(int count) throws IllegalActionException {
  int iterations=count;
  if (count == 0) {
    iterations=computeIterations();
  }
  _headerSent=false;
  return super.iterate(iterations);
}
Program: 73685
Project: 73685
Buggy source:
/** 
 * Read the contents of the array, and extract the header containing  the number of dimensions and the size of each dimension at the beginning of the array then send only the useful informations.
 */
public void fire() throws IllegalActionException {
  IOPort portIn=(IOPort)getPort("String_Node_Str");
  IOPort portOut=(IOPort)getPort("String_Node_Str");
  Token[] tokensIn=null;
  int nDims=((IntToken)portIn.get(0)).intValue();
  int nbTokens=((IntToken)portIn.get(0)).intValue();
  Token[] headerIn=portIn.get(0,nDims * 2);
  int dataSize=nbTokens;
  String[] dims=new String[nDims];
  int[] sizes=new int[dims.length];
  for (int i=0; i < nDims; i++) {
    dataSize*=((IntToken)headerIn[2 * i + 1]).intValue();
    dims[i]=((StringToken)headerIn[2 * i]).stringValue();
    sizes[i]=((IntToken)headerIn[2 * i + 1]).intValue();
  }
  PthalesIOPort.modifyPattern(portOut,"String_Node_Str",dataSize);
  PthalesIOPort.modifyPattern(portIn,dims,sizes);
  tokensIn=portIn.get(0,dataSize);
  for (int i=0; i < portOut.getWidth(); i++) {
    portOut.send(i,tokensIn,dataSize);
  }
}

Fixed version (ground truth):
/** 
 * Read the contents of the array, and extract the header containing  the number of dimensions and the size of each dimension at the beginning of the array then send only the useful informations.
 */
public void fire() throws IllegalActionException {
  IOPort portIn=(IOPort)getPort("String_Node_Str");
  IOPort portOut=(IOPort)getPort("String_Node_Str");
  Token[] tokensIn=null;
  int nDims=((IntToken)portIn.get(0)).intValue();
  int nbTokens=((IntToken)portIn.get(0)).intValue();
  Token[] headerIn=portIn.get(0,nDims * 2);
  int dataSize=nbTokens;
  String[] dims=new String[nDims];
  int[] sizes=new int[dims.length];
  for (int i=0; i < nDims; i++) {
    dataSize*=((IntToken)headerIn[2 * i + 1]).intValue();
    dims[i]=((StringToken)headerIn[2 * i]).stringValue();
    sizes[i]=((IntToken)headerIn[2 * i + 1]).intValue();
  }
  tokensIn=portIn.get(0,dataSize);
  for (int i=0; i < portOut.getWidth(); i++) {
    portOut.send(i,tokensIn,dataSize);
  }
}
Program: 73688
Project: 73688
Buggy source:
private void updateCache(XMLDBModel xmlDBModel) throws DBConnectionException, DBExecutionException {
  ArrayList<XMLDBModel> hierarchy=new ArrayList();
  ArrayList<XMLDBModel> modelsToRemoveList=new ArrayList();
  DBConnection dbConnection=null;
  try {
    dbConnection=DBConnectorFactory.getSyncConnection(false);
    ArrayList<XMLDBModel> modelList=new ArrayList();
    modelList.add(xmlDBModel);
    FetchHierarchyTask fetchHierarchyTask=new FetchHierarchyTask();
    fetchHierarchyTask.setModelsList(modelList);
    hierarchy=dbConnection.executeFetchHierarchyTask(fetchHierarchyTask);
    if (hierarchy != null && hierarchy.size() > 0) {
      if (hierarchy.get(0) != null) {
        if (hierarchy.get(0).getParents() != null) {
          for (          List<XMLDBModel> branch : hierarchy.get(0).getParents()) {
            for (            XMLDBModel modelToRemove : branch) {
              if (!modelsToRemoveList.contains(modelToRemove)) {
                modelsToRemoveList.add(modelToRemove);
              }
            }
          }
        }
      }
    }
  }
 catch (  DBExecutionException dbEx) {
    throw dbEx;
  }
 finally {
    if (dbConnection != null) {
      dbConnection.closeConnection();
    }
  }
  modelsToRemoveList.add(xmlDBModel);
  HashSet set=new HashSet();
  for (int i=0; i < modelsToRemoveList.size(); i++) {
    boolean val=set.add(modelsToRemoveList.get(i).getModel());
    if (val == false) {
      modelsToRemoveList.remove(i);
    }
  }
  CacheManager.removeFromCache(modelsToRemoveList);
}

Fixed version (ground truth):
private void updateCache(XMLDBModel xmlDBModel) throws DBConnectionException, DBExecutionException {
  ArrayList<XMLDBModel> hierarchy=new ArrayList();
  ArrayList<XMLDBModel> modelsToRemoveList=new ArrayList();
  DBConnection dbConnection=null;
  try {
    dbConnection=DBConnectorFactory.getSyncConnection(false);
    ArrayList<XMLDBModel> modelList=new ArrayList();
    modelList.add(xmlDBModel);
    FetchHierarchyTask fetchHierarchyTask=new FetchHierarchyTask();
    fetchHierarchyTask.setModelsList(modelList);
    hierarchy=dbConnection.executeFetchHierarchyTask(fetchHierarchyTask);
    if (hierarchy != null && hierarchy.size() > 0) {
      if (hierarchy.get(0) != null) {
        if (hierarchy.get(0).getParents() != null) {
          for (          List<XMLDBModel> branch : hierarchy.get(0).getParents()) {
            for (            XMLDBModel modelToRemove : branch) {
              if (!modelsToRemoveList.contains(modelToRemove)) {
                modelsToRemoveList.add(modelToRemove);
              }
            }
          }
        }
      }
    }
  }
 catch (  DBExecutionException dbEx) {
    throw dbEx;
  }
 finally {
    if (dbConnection != null) {
      dbConnection.closeConnection();
    }
  }
  modelsToRemoveList.add(xmlDBModel);
  CacheManager.removeFromCache(modelsToRemoveList);
}
Program: 73690
Project: 73690
Buggy source:
/** 
 * Validate whether the search criteria that the user has input is valid or  not. 
 * @return true - the search criteria is valid.<br>false - the search criteria is invalid. 
 * @exception NameDuplicationException Thrown if attributes with duplicatednames are found in the search criteria. 
 * @exception IllegalActionException Thrown if the intend action is illegal. 
 */
private boolean _isValid() throws NameDuplicationException, IllegalActionException {
  if (_attributesListPanel.getAttributeCount() == 0 && _attributesListPanel.getModelName().trim().isEmpty()) {
    return true;
  }
  if (!_attributesListPanel.getModelName().trim().isEmpty()) {
    if (!_attributesListPanel.getModelName().matches("String_Node_Str")) {
      JOptionPane.showMessageDialog(this,"String_Node_Str" + "String_Node_Str","String_Node_Str",JOptionPane.INFORMATION_MESSAGE,null);
      return false;
    }
  }
  if (_attributesListPanel.containsDuplicates()) {
    JOptionPane.showMessageDialog(this,"String_Node_Str" + "String_Node_Str" + "String_Node_Str","String_Node_Str",JOptionPane.INFORMATION_MESSAGE,null);
    return false;
  }
  if (!_attributesListPanel.allAttributeNamesSet()) {
    JOptionPane.showMessageDialog(this,"String_Node_Str","String_Node_Str",JOptionPane.INFORMATION_MESSAGE,null);
    return false;
  }
  if (!_attributesListPanel.allAttributeValuesSet()) {
    JOptionPane.showMessageDialog(this,"String_Node_Str","String_Node_Str",JOptionPane.INFORMATION_MESSAGE,null);
    return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Validate whether the search criteria that the user has input is valid or  not. 
 * @return true - the search criteria is valid.<br>false - the search criteria is invalid. 
 * @exception NameDuplicationException Thrown if attributes with duplicatednames are found in the search criteria. 
 * @exception IllegalActionException Thrown if the intend action is illegal. 
 */
private boolean _isValid() throws NameDuplicationException, IllegalActionException {
  if (_attributesListPanel.getAttributeCount() == 0 && _attributesListPanel.getModelName().trim().isEmpty()) {
    return true;
  }
  if (!_attributesListPanel.getModelName().trim().isEmpty()) {
    if (!Utilities.checkAttributeModelName(_attributesListPanel.getModelName())) {
      JOptionPane.showMessageDialog(this,"String_Node_Str" + "String_Node_Str","String_Node_Str",JOptionPane.INFORMATION_MESSAGE,null);
      return false;
    }
  }
  if (_attributesListPanel.containsDuplicates()) {
    JOptionPane.showMessageDialog(this,"String_Node_Str" + "String_Node_Str" + "String_Node_Str","String_Node_Str",JOptionPane.INFORMATION_MESSAGE,null);
    return false;
  }
  if (!_attributesListPanel.allAttributeNamesSet()) {
    JOptionPane.showMessageDialog(this,"String_Node_Str","String_Node_Str",JOptionPane.INFORMATION_MESSAGE,null);
    return false;
  }
  if (!_attributesListPanel.allAttributeValuesSet()) {
    JOptionPane.showMessageDialog(this,"String_Node_Str","String_Node_Str",JOptionPane.INFORMATION_MESSAGE,null);
    return false;
  }
  return true;
}
Program: 73691
Project: 73691
Buggy source:
/** 
 * Validate whether the added item is valid to add to the list. 
 * @return true - It is valid to add that item.<br>false - It is invalid to add that item.
 */
private boolean _validate(){
  ArrayModelList modelList=((ArrayModelList)_itemsJList.getModel());
  for (int i=0; i < modelList.getSize(); i++) {
    if (_listItemTextField.getText().equals(modelList.getElementAt(i))) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Validate whether the added item is valid to add to the list. 
 * @return true - It is valid to add that item.<br>false - It is invalid to add that item.
 */
private boolean _validate(){
  if (!Utilities.checkAttributeModelName(_listItemTextField.getText())) {
    return false;
  }
  ArrayModelList modelList=((ArrayModelList)_itemsJList.getModel());
  for (int i=0; i < modelList.getSize(); i++) {
    if (_listItemTextField.getText().equals(modelList.getElementAt(i))) {
      return false;
    }
  }
  return true;
}
Program: 73692
Project: 73692
Buggy source:
private void _saveModel() throws Exception {
  try {
    _modelToSave.setName(_attributesListPanel.getModelName());
    if (_initialModelName != null && _initialModelName.length() > 0) {
      if (!_modelToSave.getName().equals(_initialModelName)) {
        Object[] options={"String_Node_Str","String_Node_Str","String_Node_Str"};
        int n=JOptionPane.showOptionDialog(this,"String_Node_Str" + "String_Node_Str","String_Node_Str",JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE,null,options,options[2]);
        if (n != JOptionPane.YES_OPTION) {
          return;
        }
      }
    }
    String id=null;
    if (_modelToSave.getAttribute(XMLDBModel.DB_MODEL_ID_ATTR) != null) {
      id=((StringParameter)_modelToSave.getAttribute(XMLDBModel.DB_MODEL_ID_ATTR)).getExpression();
    }
    _commitSave(_isNew(),id);
  }
 catch (  DBConnectionException exception) {
    throw exception;
  }
catch (  DBExecutionException exception) {
    throw exception;
  }
catch (  IllegalArgumentException exception) {
    throw exception;
  }
}

Fixed version (ground truth):
private void _saveModel() throws Exception {
  try {
    _modelToSave.setName(_attributesListPanel.getModelName());
    if (_initialModelName != null && _initialModelName.length() > 0) {
      if (!_modelToSave.getName().equals(_initialModelName)) {
        Object[] options={"String_Node_Str","String_Node_Str","String_Node_Str"};
        int n=JOptionPane.showOptionDialog(this,"String_Node_Str" + "String_Node_Str","String_Node_Str",JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE,null,options,options[2]);
        if (n != JOptionPane.YES_OPTION) {
          return;
        }
      }
    }
    String id=null;
    if (_modelToSave.getAttribute(XMLDBModel.DB_MODEL_ID_ATTR) != null) {
      id=((StringConstantParameter)_modelToSave.getAttribute(XMLDBModel.DB_MODEL_ID_ATTR)).getExpression();
    }
    _commitSave(_isNew(),id);
  }
 catch (  DBConnectionException exception) {
    throw exception;
  }
catch (  DBExecutionException exception) {
    throw exception;
  }
catch (  IllegalArgumentException exception) {
    throw exception;
  }
}
Program: 73694
Project: 73694
Buggy source:
/** 
 * Construct a XMLDBModel instance with the given model name.
 * @param modelName the name for the given model.
 */
public XMLDBModel(String modelName){
  this._modelName=modelName;
}

Fixed version (ground truth):
/** 
 * Construct a XMLDBModel instance with the given model name.
 * @param modelName Name for the given model.
 * @param modelId Id for the given model.
 */
public XMLDBModel(String modelName,String modelId){
  this._modelName=modelName;
  this._modelId=modelId;
}
Program: 73696
Project: 73696
Buggy source:
/** 
 * Abort the connection and roll back the transaction Invoke in case of errors.
 * @exception DBConnectionException If thrown while aborting transaction inthe database.
 */
public void abortConnection() throws DBConnectionException {
  try {
    _checkConnectionAlive();
    if (_xmlTransaction != null) {
      _checkTransactionActive();
      _xmlTransaction.abort();
      _isTransactionActive=false;
    }
  }
 catch (  XmlException e) {
    throw new DBConnectionException("String_Node_Str" + e.getMessage(),e);
  }
}

Fixed version (ground truth):
/** 
 * Abort the connection and roll back the transaction Invoke in case of errors.
 * @exception DBConnectionException If thrown while aborting transaction inthe database.
 */
public void abortConnection() throws DBConnectionException {
  try {
    _checkConnectionAlive();
    if (_xmlTransaction != null) {
      _checkTransactionActive();
      _xmlTransaction.getTransaction().abort();
      _isTransactionActive=false;
    }
  }
 catch (  XmlException e) {
    throw new DBConnectionException("String_Node_Str" + e.getMessage(),e);
  }
catch (  DatabaseException e) {
    throw new DBConnectionException("String_Node_Str" + e.getMessage(),e);
  }
}
Program: 73697
Project: 73697
Buggy source:
/** 
 * Fetch the parent hierarchies for the given model.
 * @param model The model for which the parent hierarchies are required.
 * @exception DBExecutionException If thrown while fetching model hierarchy.
 * @throws XMLDBModelParsingException If thrown while parsing the model.
 */
private XMLDBModel _fetchHierarchyForModel(XMLDBModel model) throws DBExecutionException, XMLDBModelParsingException {
  String referencesXML=_getParentHierarchiesForModelFromDB(model);
  if (referencesXML != null) {
    Document document=(Document)Utilities.parseXML(referencesXML);
    Node firstNode=document.getElementsByTagName("String_Node_Str").item(0);
    if (firstNode != null) {
      HashMap<String,DBModel> dBModelsMap=new HashMap<String,DBModel>();
      String modelName=model.getModelName();
      dBModelsMap.put(modelName,new DBModel(modelName));
      NodeList children=firstNode.getChildNodes();
      for (int i=0; i < children.getLength(); i++) {
        if (children.item(i).getNodeType() == Node.ELEMENT_NODE) {
          Node child=children.item(i);
          _createParentHierarchy(child,null,dBModelsMap,model);
        }
      }
      DBModel baseDBModel=dBModelsMap.get(model.getModelName());
      _populateParentList(model,baseDBModel,new LinkedList<XMLDBModel>(),model);
    }
  }
  return model;
}

Fixed version (ground truth):
/** 
 * Fetch the parent hierarchies for the given model.
 * @param model The model for which the parent hierarchies are required.
 * @exception DBExecutionException If thrown while fetching model hierarchy.
 * @throws XMLDBModelParsingException If thrown while parsing the model.
 */
private XMLDBModel _fetchHierarchyForModel(XMLDBModel model) throws DBExecutionException, XMLDBModelParsingException {
  String referencesXML=_getParentHierarchiesForModelFromDB(model);
  if (referencesXML != null) {
    Document document=(Document)Utilities.parseXML(referencesXML);
    Node firstNode=document.getElementsByTagName("String_Node_Str").item(0);
    if (firstNode != null) {
      HashMap<String,DBModel> dBModelsMap=new HashMap<String,DBModel>();
      String modelId=model.getModelId();
      dBModelsMap.put(modelId,new DBModel(model.getModelName(),modelId));
      NodeList children=firstNode.getChildNodes();
      for (int i=0; i < children.getLength(); i++) {
        if (children.item(i).getNodeType() == Node.ELEMENT_NODE) {
          Node child=children.item(i);
          _createParentHierarchy(child,null,dBModelsMap,model);
        }
      }
      DBModel baseDBModel=dBModelsMap.get(model.getModelId());
      _populateParentList(model,baseDBModel,new LinkedList<XMLDBModel>(),model);
    }
  }
  return model;
}
Program: 73698
Project: 73698
Buggy source:
/** 
 * Execute the attribute search on the database for the given attribute clause.
 * @param attributeClause Attribute sub-query for which search needs to bedone.
 * @return List of models matching the attribute search.
 * @exception XmlException If thrown while executing query.
 * @exception DBExecutionException Thrown if the query context is notinitialized properly.
 */
private ArrayList<String> _executeSingleAttributeMatch(String attributeClause) throws XmlException, DBExecutionException {
  ArrayList<String> modelsList=new ArrayList<String>();
  String attributeSearchQuery="String_Node_Str" + _params.getContainerName() + "String_Node_Str"+ attributeClause+ "String_Node_Str"+ "String_Node_Str";
  System.out.println("String_Node_Str" + attributeSearchQuery);
  XmlQueryContext context=_xmlManager.createQueryContext();
  if (context == null)   throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
  context.setEvaluationType(XmlQueryContext.Lazy);
  XmlResults results=_xmlManager.query(attributeSearchQuery,context,null);
  if (results != null) {
    XmlValue value;
    while (results.hasNext()) {
      value=results.next();
      modelsList.add(value.asString());
    }
  }
  return modelsList;
}

Fixed version (ground truth):
/** 
 * Execute the attribute search on the database for the given attribute clause.
 * @param attributeClause Attribute sub-query for which search needs to bedone.
 * @return List of models matching the attribute search.
 * @exception XmlException If thrown while executing query.
 * @exception DBExecutionException Thrown if the query context is notinitialized properly.
 */
private ArrayList<String> _executeSingleAttributeMatch(String attributeClause) throws XmlException, DBExecutionException {
  ArrayList<String> modelsList=new ArrayList<String>();
  String attributeSearchQuery="String_Node_Str" + _params.getContainerName() + "String_Node_Str"+ attributeClause+ "String_Node_Str"+ "String_Node_Str";
  XmlQueryContext context=_xmlManager.createQueryContext();
  if (context == null)   throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
  context.setEvaluationType(XmlQueryContext.Lazy);
  XmlResults results=_xmlManager.query(attributeSearchQuery,context,null);
  if (results != null) {
    XmlValue value;
    while (results.hasNext()) {
      value=results.next();
      modelsList.add(value.asString());
    }
  }
  return modelsList;
}
Program: 73699
Project: 73699
Buggy source:
/** 
 * Extract model name from the given string.
 * @param completeModelName Model name with container name.
 * @return Model name 
 */
public String _extractModelName(String completeModelName){
  if (completeModelName != null) {
    return completeModelName.substring(completeModelName.lastIndexOf("String_Node_Str") + 1);
  }
 else   return completeModelName;
}

Fixed version (ground truth):
/** 
 * Extract model name from the given string.
 * @param completeModelName Model name with container name.
 * @return Model name 
 */
private String _extractModelName(String completeModelName){
  if (completeModelName != null) {
    return completeModelName.substring(completeModelName.lastIndexOf("String_Node_Str") + 1);
  }
 else   return completeModelName;
}
Program: 73700
Project: 73700
Buggy source:
/** 
 * Create a database environment with the given configuration.
 * @param url Database URL
 * @throws DBConnectionException If thrown while creating the environment.
 */
public static void initializeDatabase(String url) throws DBConnectionException {
  if (!Utilities.checkFileExists(url)) {
    throw new DBConnectionException("String_Node_Str");
  }
  EnvironmentConfig config=new EnvironmentConfig();
  config.setRunRecovery(true);
  config.setCacheSize(5 * 1024 * 1024);
  config.setAllowCreate(true);
  config.setInitializeCache(true);
  config.setTransactional(true);
  config.setInitializeLocking(true);
  config.setInitializeLogging(true);
  config.setErrorStream(System.err);
  config.setMaxLockers(1000);
  config.setMaxLocks(1000);
  config.setMaxLockObjects(1000);
  config.setLockDetectMode(LockDetectMode.DEFAULT);
  File dbFile=new File(url);
  try {
    try {
      if (_environment != null)       _environment.close();
    }
 catch (    Exception e) {
    }
    _environment=new Environment(dbFile,config);
    _environmentPath=url;
  }
 catch (  FileNotFoundException e) {
    throw new DBConnectionException("String_Node_Str" + e.getMessage());
  }
catch (  DatabaseException e) {
    throw new DBConnectionException("String_Node_Str" + e.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Create a database environment with the given configuration.
 * @param url Database URL
 * @throws DBConnectionException If thrown while creating the environment.
 */
public static void initializeDatabase(String url) throws DBConnectionException {
  if (!Utilities.checkFileExists(url)) {
    throw new DBConnectionException("String_Node_Str");
  }
  EnvironmentConfig config=new EnvironmentConfig();
  config.setRunRecovery(true);
  config.setCacheSize(5 * 1024 * 1024);
  config.setAllowCreate(true);
  config.setInitializeCache(true);
  config.setTransactional(true);
  config.setInitializeLocking(true);
  config.setInitializeLogging(true);
  config.setErrorStream(System.err);
  config.setJoinEnvironment(true);
  config.setNoLocking(true);
  File dbFile=new File(url);
  try {
    try {
      if (_environment != null)       _environment.close();
    }
 catch (    Exception e) {
    }
    _environment=new Environment(dbFile,config);
    _environmentPath=url;
  }
 catch (  FileNotFoundException e) {
    throw new DBConnectionException("String_Node_Str" + e.getMessage());
  }
catch (  DatabaseException e) {
    throw new DBConnectionException("String_Node_Str" + e.getMessage());
  }
}
Program: 73701
Project: 73701
Buggy source:
/** 
 * @param query Search xQuery that needs to be executed.  
 * @param matchedModelsList Models within which we need to search for the given query criterion.
 * @return Returns a List of matching model names.
 * @throws DBExecutionException If thrown while searching in the database.
 */
private ArrayList<String> _executeGraphSearchQuery(String query,ArrayList<String> matchedModelsList) throws DBExecutionException {
  ArrayList<String> modelsList=new ArrayList<String>();
  System.out.println("String_Node_Str" + query);
  XmlQueryContext context;
  try {
    context=_xmlManager.createQueryContext();
    if (context == null)     throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    context.setEvaluationType(XmlQueryContext.Lazy);
    XmlResults results=_xmlManager.query(query,context,null);
    if (results != null) {
      XmlValue value;
      while (results.hasNext()) {
        value=results.next();
        modelsList.add(value.asString());
      }
    }
    if (matchedModelsList != null) {
      modelsList.retainAll(matchedModelsList);
    }
  }
 catch (  XmlException e) {
    throw new DBExecutionException("String_Node_Str" + e.getMessage(),e);
  }
  return modelsList;
}

Fixed version (ground truth):
/** 
 * @param query Search xQuery that needs to be executed.  
 * @param matchedModelsList Models within which we need to search for the given query criterion.
 * @return Returns a List of matching model names.
 * @throws DBExecutionException If thrown while searching in the database.
 */
private ArrayList<String> _executeGraphSearchQuery(String query,ArrayList<String> matchedModelsList) throws DBExecutionException {
  ArrayList<String> modelsList=new ArrayList<String>();
  XmlQueryContext context;
  try {
    context=_xmlManager.createQueryContext();
    if (context == null)     throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    context.setEvaluationType(XmlQueryContext.Lazy);
    XmlResults results=_xmlManager.query(query,context,null);
    if (results != null) {
      XmlValue value;
      while (results.hasNext()) {
        value=results.next();
        modelsList.add(value.asString());
      }
    }
    if (matchedModelsList != null) {
      modelsList.retainAll(matchedModelsList);
    }
  }
 catch (  XmlException e) {
    throw new DBExecutionException("String_Node_Str" + e.getMessage(),e);
  }
  return modelsList;
}
Program: 73702
Project: 73702
Buggy source:
/** 
 * Populate the base model with the maximal parent hierarchies.
 * @param model XMLDBModel in the hierarchy.
 * @param dbModel DBModel for the above XMLDBModel.
 * @param childHierarchy List that contains the list if previous modelsvisited in the hierarchy.
 * @param baseModel Base model for which the parent hierarchies need to bepopulated.
 */
private void _populateParentList(XMLDBModel model,DBModel dbModel,LinkedList<XMLDBModel> childHierarchy,XMLDBModel baseModel){
  ArrayList<DBModel> parentsList=dbModel._parentsList;
  if (parentsList != null && parentsList.size() > 0) {
    childHierarchy.addFirst(model);
    for (    DBModel parentDBModel : parentsList) {
      XMLDBModel parentXMLDBModel=new XMLDBModel(parentDBModel._modelName);
      _populateParentList(parentXMLDBModel,parentDBModel,childHierarchy,baseModel);
    }
    childHierarchy.removeFirst();
  }
 else {
    LinkedList<XMLDBModel> xmlDBModelParentsList=new LinkedList<XMLDBModel>();
    xmlDBModelParentsList.addAll(childHierarchy);
    xmlDBModelParentsList.addFirst(model);
    baseModel.addParentList(xmlDBModelParentsList);
  }
}

Fixed version (ground truth):
/** 
 * Populate the base model with the maximal parent hierarchies.
 * @param model XMLDBModel in the hierarchy.
 * @param dbModel DBModel for the above XMLDBModel.
 * @param childHierarchy List that contains the list if previous modelsvisited in the hierarchy.
 * @param baseModel Base model for which the parent hierarchies need to bepopulated.
 */
private void _populateParentList(XMLDBModel model,DBModel dbModel,LinkedList<XMLDBModel> childHierarchy,XMLDBModel baseModel){
  ArrayList<DBModel> parentsList=dbModel._parentsList;
  if (parentsList != null && parentsList.size() > 0) {
    childHierarchy.addFirst(model);
    for (    DBModel parentDBModel : parentsList) {
      XMLDBModel parentXMLDBModel=new XMLDBModel(parentDBModel._modelName,parentDBModel._modelId);
      _populateParentList(parentXMLDBModel,parentDBModel,childHierarchy,baseModel);
    }
    childHierarchy.removeFirst();
  }
 else {
    LinkedList<XMLDBModel> xmlDBModelParentsList=new LinkedList<XMLDBModel>();
    xmlDBModelParentsList.addAll(childHierarchy);
    xmlDBModelParentsList.addFirst(model);
    xmlDBModelParentsList.removeLast();
    baseModel.addParentList(xmlDBModelParentsList);
  }
}
Program: 73703
Project: 73703
Buggy source:
/** 
 * Create the parent hierarchy for the given base model.
 * @param currentNode Current node for which processing needs to be done.
 * @param parentNodeName Parent node for the current node.
 * @param dBModelsMap Map that contains all the DBModels as they are createdso that their parent lists can be populated.
 * @param baseModel Base model for which the hierarchy is being created.
 */
private void _createParentHierarchy(Node currentNode,String parentNodeName,HashMap<String,DBModel> dBModelsMap,XMLDBModel baseModel){
  String currentNodeName=Utilities.getValueForAttribute(currentNode,XMLDBModel.DB_MODEL_ID_ATTR);
  if (currentNodeName != null) {
    if (!dBModelsMap.containsKey(currentNodeName) && currentNode.hasChildNodes()) {
      NodeList children=currentNode.getChildNodes();
      for (int i=0; i < children.getLength(); i++) {
        if (children.item(i).getNodeType() == Node.ELEMENT_NODE) {
          Node child=children.item(i);
          _createParentHierarchy(child,currentNodeName,dBModelsMap,baseModel);
        }
      }
    }
    if (parentNodeName != null && dBModelsMap.containsKey(currentNodeName)) {
      DBModel currentDBModel=dBModelsMap.get(currentNodeName);
      DBModel parentDBModel=new DBModel(parentNodeName);
      currentDBModel.addParent(parentDBModel);
      dBModelsMap.put(parentNodeName,parentDBModel);
    }
  }
}

Fixed version (ground truth):
/** 
 * Create the parent hierarchy for the given base model.
 * @param currentNode Current node for which processing needs to be done.
 * @param parentNodeId Parent node for the current node.
 * @param dBModelsMap Map that contains all the DBModels as they are createdso that their parent lists can be populated.
 * @param baseModel Base model for which the hierarchy is being created.
 * @throws DBExecutionException 
 */
private void _createParentHierarchy(Node currentNode,String parentNodeId,HashMap<String,DBModel> dBModelsMap,XMLDBModel baseModel) throws DBExecutionException {
  String currentNodeId=Utilities.getValueForAttribute(currentNode,XMLDBModel.DB_MODEL_ID_ATTR);
  if (currentNodeId != null) {
    if (!dBModelsMap.containsKey(currentNodeId) && currentNode.hasChildNodes()) {
      NodeList children=currentNode.getChildNodes();
      for (int i=0; i < children.getLength(); i++) {
        if (children.item(i).getNodeType() == Node.ELEMENT_NODE) {
          Node child=children.item(i);
          _createParentHierarchy(child,currentNodeId,dBModelsMap,baseModel);
        }
      }
    }
    if (parentNodeId != null && dBModelsMap.containsKey(currentNodeId)) {
      DBModel currentDBModel=dBModelsMap.get(currentNodeId);
      String modelName=_getModelNameFromModelId(parentNodeId);
      DBModel parentDBModel=new DBModel(modelName,parentNodeId);
      currentDBModel.addParent(parentDBModel);
      dBModelsMap.put(parentNodeId,parentDBModel);
    }
  }
}
Program: 73704
Project: 73704
Buggy source:
/** 
 * Construct an instance with the given model name.
 */
DBModel(String modelName){
  _modelName=modelName;
}

Fixed version (ground truth):
/** 
 * Construct an instance with the given model name.
 */
DBModel(String modelName,String modelId){
  _modelId=modelId;
  _modelName=modelName;
}
Program: 73706
Project: 73706
Buggy source:
private void updateCache(XMLDBModel xmlDBModel) throws DBConnectionException, DBExecutionException {
  ArrayList<XMLDBModel> hierarchy=new ArrayList();
  ArrayList<XMLDBModel> modelsToRemoveList=new ArrayList();
  DBConnection dbConnection=null;
  try {
    dbConnection=DBConnectorFactory.getSyncConnection(false);
    ArrayList<XMLDBModel> modelList=new ArrayList();
    modelList.add(xmlDBModel);
    FetchHierarchyTask fetchHierarchyTask=new FetchHierarchyTask();
    fetchHierarchyTask.setModelsList(modelList);
    hierarchy=dbConnection.executeFetchHierarchyTask(fetchHierarchyTask);
    if (hierarchy != null && hierarchy.size() > 0) {
      if (hierarchy.get(0) != null) {
        if (hierarchy.get(0).getParents() != null) {
          for (          List<XMLDBModel> branch : hierarchy.get(0).getParents()) {
            for (            XMLDBModel modelToRemove : branch) {
              if (!modelsToRemoveList.contains(modelToRemove)) {
                modelsToRemoveList.add(modelToRemove);
              }
            }
          }
        }
      }
    }
  }
 catch (  DBExecutionException dbEx) {
    throw dbEx;
  }
 finally {
    if (dbConnection != null) {
      dbConnection.closeConnection();
    }
  }
  modelsToRemoveList.add(xmlDBModel);
  HashSet set=new HashSet();
  for (int i=0; i < modelsToRemoveList.size(); i++) {
    boolean val=set.add(modelsToRemoveList.get(i).getModel());
    if (val == false) {
      modelsToRemoveList.remove(i);
    }
  }
  CacheManager.removeFromCache(hierarchy);
}

Fixed version (ground truth):
private void updateCache(XMLDBModel xmlDBModel) throws DBConnectionException, DBExecutionException {
  ArrayList<XMLDBModel> hierarchy=new ArrayList();
  ArrayList<XMLDBModel> modelsToRemoveList=new ArrayList();
  DBConnection dbConnection=null;
  try {
    dbConnection=DBConnectorFactory.getSyncConnection(false);
    ArrayList<XMLDBModel> modelList=new ArrayList();
    modelList.add(xmlDBModel);
    FetchHierarchyTask fetchHierarchyTask=new FetchHierarchyTask();
    fetchHierarchyTask.setModelsList(modelList);
    hierarchy=dbConnection.executeFetchHierarchyTask(fetchHierarchyTask);
    if (hierarchy != null && hierarchy.size() > 0) {
      if (hierarchy.get(0) != null) {
        if (hierarchy.get(0).getParents() != null) {
          for (          List<XMLDBModel> branch : hierarchy.get(0).getParents()) {
            for (            XMLDBModel modelToRemove : branch) {
              if (!modelsToRemoveList.contains(modelToRemove)) {
                modelsToRemoveList.add(modelToRemove);
              }
            }
          }
        }
      }
    }
  }
 catch (  DBExecutionException dbEx) {
    throw dbEx;
  }
 finally {
    if (dbConnection != null) {
      dbConnection.closeConnection();
    }
  }
  modelsToRemoveList.add(xmlDBModel);
  HashSet set=new HashSet();
  for (int i=0; i < modelsToRemoveList.size(); i++) {
    boolean val=set.add(modelsToRemoveList.get(i).getModel());
    if (val == false) {
      modelsToRemoveList.remove(i);
    }
  }
  CacheManager.removeFromCache(modelsToRemoveList);
}