Program: 116888
Project: 116888
Buggy source:
/** 
 * Decreases the priority of an overrideId
 * @param overrideId Id of override to edit
 * @param pathId ID of path containing override
 * @param clientUUID ID of client
 */
public void decreasePriority(int overrideId,int pathId,String clientUUID){
  logger.info("String_Node_Str");
  int origPriority=-1;
  int newPriority=-1;
  PreparedStatement queryStatement=null;
  ResultSet results=null;
  try (Connection sqlConnection=sqlService.getConnection()){
    queryStatement=sqlConnection.prepareStatement("String_Node_Str" + Constants.DB_TABLE_ENABLED_OVERRIDE + "String_Node_Str"+ Constants.ENABLED_OVERRIDES_PATH_ID+ "String_Node_Str"+ "String_Node_Str"+ Constants.GENERIC_CLIENT_UUID+ "String_Node_Str"+ "String_Node_Str"+ Constants.ENABLED_OVERRIDES_PRIORITY);
    queryStatement.setInt(1,pathId);
    queryStatement.setString(2,clientUUID);
    results=queryStatement.executeQuery();
    boolean gotOrig=false;
    while (results.next()) {
      if (results.getInt(Constants.ENABLED_OVERRIDES_OVERRIDE_ID) == overrideId) {
        origPriority=results.getInt(Constants.ENABLED_OVERRIDES_PRIORITY);
        gotOrig=true;
      }
 else {
        newPriority=results.getInt(Constants.ENABLED_OVERRIDES_PRIORITY);
        if (gotOrig) {
          break;
        }
      }
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
 finally {
    try {
      if (results != null) {
        results.close();
      }
    }
 catch (    Exception e) {
    }
    try {
      if (queryStatement != null) {
        queryStatement.close();
      }
    }
 catch (    Exception e) {
    }
  }
  PreparedStatement statement=null;
  try (Connection sqlConnection=sqlService.getConnection()){
    if (origPriority != -1 && newPriority != -1) {
      statement=sqlConnection.prepareStatement("String_Node_Str" + Constants.DB_TABLE_ENABLED_OVERRIDE + "String_Node_Str"+ Constants.ENABLED_OVERRIDES_PRIORITY+ "String_Node_Str"+ "String_Node_Str"+ Constants.ENABLED_OVERRIDES_PRIORITY+ "String_Node_Str"+ "String_Node_Str"+ Constants.ENABLED_OVERRIDES_PATH_ID+ "String_Node_Str"+ "String_Node_Str"+ Constants.GENERIC_CLIENT_UUID+ "String_Node_Str");
      statement.setInt(1,origPriority);
      statement.setInt(2,newPriority);
      statement.setInt(3,pathId);
      statement.setString(4,clientUUID);
      statement.executeUpdate();
      statement.close();
      statement=sqlConnection.prepareStatement("String_Node_Str" + Constants.DB_TABLE_ENABLED_OVERRIDE + "String_Node_Str"+ Constants.ENABLED_OVERRIDES_PRIORITY+ "String_Node_Str"+ "String_Node_Str"+ Constants.ENABLED_OVERRIDES_OVERRIDE_ID+ "String_Node_Str"+ "String_Node_Str"+ Constants.ENABLED_OVERRIDES_PATH_ID+ "String_Node_Str"+ "String_Node_Str"+ Constants.GENERIC_CLIENT_UUID+ "String_Node_Str");
      statement.setInt(1,newPriority);
      statement.setInt(2,overrideId);
      statement.setInt(3,pathId);
      statement.setString(4,clientUUID);
      statement.executeUpdate();
    }
  }
 catch (  Exception e) {
  }
 finally {
    try {
      if (statement != null) {
        statement.close();
      }
    }
 catch (    Exception e) {
    }
  }
}

Fixed version (ground truth):
/** 
 * Decreases the priority of an overrideId
 * @param overrideId Id of override to edit
 * @param pathId ID of path containing override
 * @param clientUUID ID of client
 */
public void decreasePriority(int overrideId,int ordinal,int pathId,String clientUUID){
  logger.info("String_Node_Str");
  int origPriority=-1;
  int newPriority=-1;
  int origId=0;
  int newId=0;
  PreparedStatement queryStatement=null;
  ResultSet results=null;
  try (Connection sqlConnection=sqlService.getConnection()){
    queryStatement=sqlConnection.prepareStatement("String_Node_Str" + Constants.DB_TABLE_ENABLED_OVERRIDE + "String_Node_Str"+ Constants.ENABLED_OVERRIDES_PATH_ID+ "String_Node_Str"+ "String_Node_Str"+ Constants.GENERIC_CLIENT_UUID+ "String_Node_Str"+ "String_Node_Str"+ Constants.ENABLED_OVERRIDES_PRIORITY);
    queryStatement.setInt(1,pathId);
    queryStatement.setString(2,clientUUID);
    results=queryStatement.executeQuery();
    boolean gotOrig=false;
    int ordinalCount=0;
    while (results.next()) {
      if (results.getInt(Constants.ENABLED_OVERRIDES_OVERRIDE_ID) == overrideId) {
        ordinalCount++;
        if (ordinalCount == ordinal) {
          origPriority=results.getInt(Constants.ENABLED_OVERRIDES_PRIORITY);
          origId=results.getInt(Constants.GENERIC_ID);
          gotOrig=true;
          continue;
        }
      }
      newPriority=results.getInt(Constants.ENABLED_OVERRIDES_PRIORITY);
      newId=results.getInt(Constants.GENERIC_ID);
      if (gotOrig) {
        break;
      }
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
 finally {
    try {
      if (results != null) {
        results.close();
      }
    }
 catch (    Exception e) {
    }
    try {
      if (queryStatement != null) {
        queryStatement.close();
      }
    }
 catch (    Exception e) {
    }
  }
  PreparedStatement statement=null;
  try (Connection sqlConnection=sqlService.getConnection()){
    if (origPriority != -1 && newPriority != -1) {
      statement=sqlConnection.prepareStatement("String_Node_Str" + Constants.DB_TABLE_ENABLED_OVERRIDE + "String_Node_Str"+ Constants.ENABLED_OVERRIDES_PRIORITY+ "String_Node_Str"+ "String_Node_Str"+ Constants.GENERIC_ID+ "String_Node_Str");
      statement.setInt(1,origPriority);
      statement.setInt(2,newId);
      statement.executeUpdate();
      statement.close();
      statement=sqlConnection.prepareStatement("String_Node_Str" + Constants.DB_TABLE_ENABLED_OVERRIDE + "String_Node_Str"+ Constants.ENABLED_OVERRIDES_PRIORITY+ "String_Node_Str"+ "String_Node_Str"+ Constants.GENERIC_ID+ "String_Node_Str");
      statement.setInt(1,newPriority);
      statement.setInt(2,origId);
      statement.executeUpdate();
    }
  }
 catch (  Exception e) {
  }
 finally {
    try {
      if (statement != null) {
        statement.close();
      }
    }
 catch (    Exception e) {
    }
  }
}