nus-yam/ex-repair huggingface dataset:
Program: 3562
Project: 3562
Buggy source:
/** 
 * Load Submission Configuration for a specific user interface(UI). The submission configuration file name is formatted as follows: item-submission-UIName.xml <P> E.g. for a value of "XMLUI", uses the config file named item-submission-XMLUI.xml
 * @param UIName the name of the UI to load the Submission configuration for
 */
public SubmissionConfigReader(String UIName) throws ServletException {
  buildInputs(configDir + SUBMIT_DEF_FILE_PREFIX + "String_Node_Str"+ UIName+ SUBMIT_DEF_FILE_SUFFIX);
}

Fixed version (ground truth):
/** 
 * Load Submission Configuration for a specific user interface(UI). The submission configuration file name is formatted as follows: item-submission-UIName.xml <P> E.g. for a value of "XMLUI", uses the config file named item-submission-XMLUI.xml
 * @param UIName the name of the UI to load the Submission configuration for
 */
public SubmissionConfigReader(String UIName) throws ServletException {
  this.UIName=UIName;
  buildInputs(configDir + SUBMIT_DEF_FILE_PREFIX + "String_Node_Str"+ UIName+ SUBMIT_DEF_FILE_SUFFIX);
}
Program: 3565
Project: 3565
Buggy source:
/** 
 * A sanity check that ensures a given element and qualifier are unique within a given schema. The check happens in code as we cannot use a database constraint.
 * @param context dspace context
 * @param schemaID
 * @param element
 * @param qualifier
 * @return true if unique
 * @throws AuthorizeException
 * @throws SQLException
 * @throws IOException
 */
private boolean unique(Context context,int schemaID,String element,String qualifier) throws IOException, SQLException, AuthorizeException {
  Connection con=context.getDBConnection();
  TableRow reg=DatabaseManager.row("String_Node_Str");
  String query="String_Node_Str" + reg.getTable() + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  PreparedStatement statement=con.prepareStatement(query);
  statement.setInt(1,schemaID);
  statement.setInt(2,fieldID);
  statement.setString(3,element);
  statement.setString(4,qualifier);
  ResultSet rs=statement.executeQuery();
  int count=0;
  if (rs.next()) {
    count=rs.getInt(1);
  }
  return (count == 0);
}

Fixed version (ground truth):
/** 
 * A sanity check that ensures a given element and qualifier are unique within a given schema. The check happens in code as we cannot use a database constraint.
 * @param context dspace context
 * @param schemaID
 * @param element
 * @param qualifier
 * @return true if unique
 * @throws AuthorizeException
 * @throws SQLException
 * @throws IOException
 */
private boolean unique(Context context,int schemaID,String element,String qualifier) throws IOException, SQLException, AuthorizeException {
  Connection con=context.getDBConnection();
  TableRow reg=DatabaseManager.row("String_Node_Str");
  String qualifierClause="String_Node_Str";
  if (qualifier == null) {
    qualifierClause="String_Node_Str";
  }
 else {
    qualifierClause="String_Node_Str";
  }
  String query="String_Node_Str" + reg.getTable() + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ qualifierClause;
  PreparedStatement statement=con.prepareStatement(query);
  statement.setInt(1,schemaID);
  statement.setInt(2,fieldID);
  statement.setString(3,element);
  if (qualifier != null) {
    statement.setString(4,qualifier);
  }
  ResultSet rs=statement.executeQuery();
  int count=0;
  if (rs.next()) {
    count=rs.getInt(1);
  }
  return (count == 0);
}
Program: 3566
Project: 3566
Buggy source:
/** 
 * Return true if there are more rows, false otherwise
 * @return - true if there are more rows, false otherwise
 * @exception SQLException -If a database error occurs while fetching values
 */
public boolean hasNext() throws SQLException {
  if (results == null) {
    return false;
  }
  if (hasAdvanced) {
    return hasNext;
  }
  hasAdvanced=true;
  hasNext=results.next();
  if (!hasNext) {
    close();
  }
  return hasNext;
}

Fixed version (ground truth):
/** 
 * Return true if there are more rows, false otherwise
 * @return - true if there are more rows, false otherwise
 * @exception SQLException -If a database error occurs while fetching values
 */
public boolean hasNext() throws SQLException {
  if (results == null) {
    close();
    return false;
  }
  if (hasAdvanced) {
    return hasNext;
  }
  hasAdvanced=true;
  hasNext=results.next();
  if (!hasNext) {
    close();
  }
  return hasNext;
}
Program: 3567
Project: 3567
Buggy source:
/** 
 * Close the Iterator and release any associated resources
 */
public void close(){
  try {
    results.close();
    if (results != null)     results.close();
  }
 catch (  SQLException sqle) {
  }
  try {
    if (statemt != null)     statemt.close();
    statemt=null;
  }
 catch (  SQLException sqle) {
  }
}

Fixed version (ground truth):
/** 
 * Close the Iterator and release any associated resources
 */
public void close(){
  try {
    if (results != null) {
      results.close();
      results=null;
    }
  }
 catch (  SQLException sqle) {
  }
  try {
    if (statemt != null) {
      statemt.close();
      statemt=null;
    }
  }
 catch (  SQLException sqle) {
  }
}
Program: 3568
Project: 3568
Buggy source:
/** 
 * get Set of Integers all of the group memberships for an eperson
 * @param c
 * @param e
 * @return Set of Integer groupIDs
 * @throws SQLException
 */
public static Set allMemberGroupIDs(Context c,EPerson e) throws SQLException {
  TableRowIterator tri=DatabaseManager.queryTable(c,"String_Node_Str","String_Node_Str",e.getID());
  Set groupIDs=new HashSet();
  while (tri.hasNext()) {
    TableRow row=tri.next();
    int childID=row.getIntColumn("String_Node_Str");
    groupIDs.add(new Integer(childID));
  }
  tri.close();
  String groupQuery="String_Node_Str";
  Iterator i=groupIDs.iterator();
  Object[] parameters=new Object[groupIDs.size()];
  int idx=0;
  while (i.hasNext()) {
    int groupID=((Integer)i.next()).intValue();
    parameters[idx++]=new Integer(groupID);
    groupQuery+="String_Node_Str";
    if (i.hasNext())     groupQuery+="String_Node_Str";
  }
  if ("String_Node_Str".equals(groupQuery)) {
    return groupIDs;
  }
  tri=DatabaseManager.queryTable(c,"String_Node_Str","String_Node_Str" + groupQuery,parameters);
  while (tri.hasNext()) {
    TableRow row=tri.next();
    int parentID=row.getIntColumn("String_Node_Str");
    groupIDs.add(new Integer(parentID));
  }
  tri.close();
  return groupIDs;
}

Fixed version (ground truth):
/** 
 * get Set of Integers all of the group memberships for an eperson
 * @param c
 * @param e
 * @return Set of Integer groupIDs
 * @throws SQLException
 */
public static Set allMemberGroupIDs(Context c,EPerson e) throws SQLException {
  TableRowIterator tri=DatabaseManager.queryTable(c,"String_Node_Str","String_Node_Str",e.getID());
  Set groupIDs=new HashSet();
  while (tri.hasNext()) {
    TableRow row=tri.next();
    int childID=row.getIntColumn("String_Node_Str");
    groupIDs.add(new Integer(childID));
  }
  tri.close();
  Group[] specialGroups=c.getSpecialGroups();
  for (int j=0; j < specialGroups.length; j++)   groupIDs.add(new Integer(specialGroups[j].getID()));
  String groupQuery="String_Node_Str";
  Iterator i=groupIDs.iterator();
  Object[] parameters=new Object[groupIDs.size()];
  int idx=0;
  while (i.hasNext()) {
    int groupID=((Integer)i.next()).intValue();
    parameters[idx++]=new Integer(groupID);
    groupQuery+="String_Node_Str";
    if (i.hasNext())     groupQuery+="String_Node_Str";
  }
  if ("String_Node_Str".equals(groupQuery)) {
    return groupIDs;
  }
  tri=DatabaseManager.queryTable(c,"String_Node_Str","String_Node_Str" + groupQuery,parameters);
  while (tri.hasNext()) {
    TableRow row=tri.next();
    int parentID=row.getIntColumn("String_Node_Str");
    groupIDs.add(new Integer(parentID));
  }
  tri.close();
  return groupIDs;
}
Program: 3569
Project: 3569
Buggy source:
/** 
 * Retrieve all e-person records from the database, sorted by a particular field. Fields are: <<<<<<< EPerson.java <ul> <li><code>ID</code></li> <li><code>LASTNAME</code></li> <li><code>EMAIL</code></li> <li><code>NETID</code></li> </ul> ======= <UL> <LI><code>ID</code></LI> <LI><code>LASTNAME</code></LI> <LI><code>EMAIL</code></LI> <LI><code>NETID</code></LI> </UL>
 * @return array of EPerson objects >>>>>>> 1.27
 */
public static EPerson[] findAll(Context context,int sortField) throws SQLException {
  String s;
switch (sortField) {
case ID:
    s="String_Node_Str";
  break;
case EMAIL:
s="String_Node_Str";
break;
case NETID:
s="String_Node_Str";
break;
default :
s="String_Node_Str";
}
TableRowIterator rows=DatabaseManager.query(context,"String_Node_Str" + s);
List epeopleRows=rows.toList();
EPerson[] epeople=new EPerson[epeopleRows.size()];
for (int i=0; i < epeopleRows.size(); i++) {
TableRow row=(TableRow)epeopleRows.get(i);
EPerson fromCache=(EPerson)context.fromCache(EPerson.class,row.getIntColumn("String_Node_Str"));
if (fromCache != null) {
epeople[i]=fromCache;
}
 else {
epeople[i]=new EPerson(context,row);
}
}
return epeople;
}

Fixed version (ground truth):
/** 
 * Retrieve all e-person records from the database, sorted by a particular field. Fields are: <ul> <li><code>ID</code></li> <li><code>LASTNAME</code></li> <li><code>EMAIL</code></li> <li><code>NETID</code></li> </ul>
 * @return array of EPerson objects
 */
public static EPerson[] findAll(Context context,int sortField) throws SQLException {
  String s;
switch (sortField) {
case ID:
    s="String_Node_Str";
  break;
case EMAIL:
s="String_Node_Str";
break;
case NETID:
s="String_Node_Str";
break;
default :
s="String_Node_Str";
}
TableRowIterator rows=DatabaseManager.query(context,"String_Node_Str" + s);
List epeopleRows=rows.toList();
EPerson[] epeople=new EPerson[epeopleRows.size()];
for (int i=0; i < epeopleRows.size(); i++) {
TableRow row=(TableRow)epeopleRows.get(i);
EPerson fromCache=(EPerson)context.fromCache(EPerson.class,row.getIntColumn("String_Node_Str"));
if (fromCache != null) {
epeople[i]=fromCache;
}
 else {
epeople[i]=new EPerson(context,row);
}
}
return epeople;
}
Program: 3571
Project: 3571
Buggy source:
private static boolean cacheMe(Class implClass){
  if (cacheMeCache.containsKey(implClass))   return ((Boolean)cacheMeCache.get(implClass)).booleanValue();
 else {
    boolean reusable=true;
    String key=REUSABLE_PREFIX + implClass.getName();
    if (ConfigurationManager.getProperty(key) != null)     reusable=ConfigurationManager.getBooleanProperty(key);
    cacheMeCache.put(implClass,new Boolean(reusable));
    return reusable;
  }
}

Fixed version (ground truth):
private static boolean cacheMe(Class implClass){
  if (cacheMeCache.containsKey(implClass)) {
    return ((Boolean)cacheMeCache.get(implClass)).booleanValue();
  }
 else {
    String key=REUSABLE_PREFIX + implClass.getName();
    boolean reusable=ConfigurationManager.getBooleanProperty(key,true);
    cacheMeCache.put(implClass,new Boolean(reusable));
    return reusable;
  }
}
Program: 3572
Project: 3572
Buggy source:
private static Object getAnonymousPlugin(String classname) throws PluginInstantiationException {
  try {
    Class pluginClass=Class.forName(classname);
    if (cacheMe(pluginClass)) {
      Object cached=anonymousInstanceCache.get(pluginClass);
      if (cached == null) {
        cached=pluginClass.newInstance();
        anonymousInstanceCache.put(pluginClass,cached);
      }
      return cached;
    }
 else     return pluginClass.newInstance();
  }
 catch (  ClassNotFoundException e) {
    throw new PluginInstantiationException("String_Node_Str",e);
  }
catch (  InstantiationException e) {
    throw new PluginInstantiationException(e);
  }
catch (  IllegalAccessException e) {
    throw new PluginInstantiationException(e);
  }
}

Fixed version (ground truth):
private static Object getAnonymousPlugin(String classname) throws PluginInstantiationException {
  try {
    Class pluginClass=Class.forName(classname);
    if (cacheMe(pluginClass)) {
      Object cached=anonymousInstanceCache.get(pluginClass);
      if (cached == null) {
        cached=pluginClass.newInstance();
        anonymousInstanceCache.put(pluginClass,cached);
      }
      return cached;
    }
 else     return pluginClass.newInstance();
  }
 catch (  ClassNotFoundException e) {
    throw new PluginInstantiationException("String_Node_Str" + e.toString(),e);
  }
catch (  InstantiationException e) {
    throw new PluginInstantiationException(e);
  }
catch (  IllegalAccessException e) {
    throw new PluginInstantiationException(e);
  }
}
Program: 3575
Project: 3575
Buggy source:
/** 
 * Prune the history records from the database.
 * @param interests set of results and the duration of time before they are removed from the database
 * @return number of bitstreams deleted
 */
public int prune(Map interests){
  Connection conn=null;
  try {
    conn=DatabaseManager.getConnection();
    long now=System.currentTimeMillis();
    int count=0;
    for (Iterator iter=interests.keySet().iterator(); iter.hasNext(); ) {
      String result=(String)iter.next();
      Long dur=(Long)interests.get(result);
      count+=deleteHistoryByDateAndCode(new Date(now - dur.longValue()),result,conn);
    }
    return count;
  }
 catch (  SQLException e) {
    LOG.error("String_Node_Str" + e.getMessage(),e);
    throw new RuntimeException("String_Node_Str" + e.getMessage(),e);
  }
 finally {
    DatabaseManager.freeConnection(conn);
  }
}

Fixed version (ground truth):
/** 
 * Prune the history records from the database.
 * @param interests set of results and the duration of time before they are removed from the database
 * @return number of bitstreams deleted
 */
public int prune(Map interests){
  Connection conn=null;
  try {
    conn=DatabaseManager.getConnection();
    long now=System.currentTimeMillis();
    int count=0;
    for (Iterator iter=interests.keySet().iterator(); iter.hasNext(); ) {
      String result=(String)iter.next();
      Long dur=(Long)interests.get(result);
      count+=deleteHistoryByDateAndCode(new Date(now - dur.longValue()),result,conn);
      conn.commit();
    }
    return count;
  }
 catch (  SQLException e) {
    LOG.error("String_Node_Str" + e.getMessage(),e);
    throw new RuntimeException("String_Node_Str" + e.getMessage(),e);
  }
 finally {
    DatabaseManager.freeConnection(conn);
  }
}
Program: 3578
Project: 3578
Buggy source:
/** 
 * Create a PreparedStatement to run the correct query for scope.
 * @param scope The Browse scope
 * @param subqueryValue If the focus is an item, this is its value in the browse index (its title, author, date, etc). Otherwise null.
 * @param after If true, create SQL to find the items after the focus. Otherwise create SQL to find the items before the focus.
 * @param isCount If true, create SQL to count the number of matches for the query. Otherwise just the query.
 * @return a prepared statement
 * @throws SQLException
 */
private static PreparedStatement createSql(BrowseScope scope,String subqueryValue,boolean after,boolean isCount) throws SQLException {
  String sqli=createSqlInternal(scope,subqueryValue,isCount);
  String sql=formatSql(scope,sqli,subqueryValue,after);
  PreparedStatement statement=createStatement(scope,sql);
  if (scope.hasFocus()) {
    String value=(subqueryValue != null) ? subqueryValue : (String)scope.getFocus();
    statement.setString(1,value);
    if (subqueryValue != null) {
      statement.setString(2,value);
    }
  }
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + sql + "String_Node_Str");
  }
  return statement;
}

Fixed version (ground truth):
/** 
 * Create a PreparedStatement to run the correct query for scope.
 * @param scope The Browse scope
 * @param subqueryValue If the focus is an item, this is its value in the browse index (its title, author, date, etc). Otherwise null.
 * @param after If true, create SQL to find the items after the focus. Otherwise create SQL to find the items before the focus.
 * @param isCount If true, create SQL to count the number of matches for the query. Otherwise just the query.
 * @return a prepared statement
 * @throws SQLException
 */
private static PreparedStatement createSql(BrowseScope scope,String subqueryValue,boolean after,boolean isCount) throws SQLException {
  String sqli=createSqlInternal(scope,subqueryValue,isCount);
  String sql=formatSql(scope,sqli,subqueryValue,after);
  PreparedStatement statement=createStatement(scope,sql);
  if (scope.hasFocus()) {
    String value=subqueryValue;
    if (value == null && scope.getFocus() instanceof String) {
      value=(String)scope.getFocus();
    }
    statement.setString(1,value);
    if (subqueryValue != null) {
      statement.setString(2,value);
    }
  }
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + sql + "String_Node_Str");
  }
  return statement;
}
Program: 3579
Project: 3579
Buggy source:
public void init(){
  String config=getServletContext().getInitParameter("String_Node_Str");
  ConfigurationManager.loadConfig(config);
  String log4jConfProp=ConfigurationManager.getProperty("String_Node_Str") + File.separator + "String_Node_Str"+ File.separator+ "String_Node_Str";
  String log4jConfXml=ConfigurationManager.getProperty("String_Node_Str") + File.separator + "String_Node_Str"+ File.separator+ "String_Node_Str";
  File xmlFile=new File(log4jConfXml);
  if (xmlFile.exists()) {
    try {
      DOMConfigurator.configure(xmlFile.toURL());
      log.info("String_Node_Str");
    }
 catch (    MalformedURLException e) {
      PropertyConfigurator.configure(log4jConfProp);
      log.error("String_Node_Str" + "String_Node_Str" + e);
    }
  }
 else {
    PropertyConfigurator.configure(log4jConfProp);
    log.info("String_Node_Str");
  }
}

Fixed version (ground truth):
public void init(){
  String config=getServletContext().getInitParameter("String_Node_Str");
  ConfigurationManager.loadConfig(config);
}
Program: 3580
Project: 3580
Buggy source:
/** 
 * Create a list of the found history records.
 * @param history the list of history records to be iterated over.
 * @param osw the output stream writer to write to.
 * @throws IOException if io error occurs
 */
private void printHistoryRecords(List history,OutputStreamWriter osw) throws IOException {
  Iterator iter=history.iterator();
  while (iter.hasNext()) {
    ChecksumHistory historyInfo=(ChecksumHistory)iter.next();
    StringBuilder buf=new StringBuilder(1000);
    buf.append("String_Node_Str");
    buf.append(msg("String_Node_Str")).append("String_Node_Str").append(historyInfo.getBitstreamId()).append("String_Node_Str");
    buf.append(msg("String_Node_Str")).append("String_Node_Str").append(DATE_FORMAT_MAX.format(historyInfo.getProcessStartDate())).append("String_Node_Str");
    buf.append(msg("String_Node_Str")).append("String_Node_Str").append(DATE_FORMAT_MAX.format(historyInfo.getProcessEndDate())).append("String_Node_Str");
    buf.append(msg("String_Node_Str")).append("String_Node_Str").append(historyInfo.getChecksumExpected()).append("String_Node_Str");
    buf.append(msg("String_Node_Str")).append("String_Node_Str").append(historyInfo.getChecksumCalculated()).append("String_Node_Str");
    buf.append(msg("String_Node_Str")).append("String_Node_Str").append(historyInfo.getResult()).append("String_Node_Str");
    buf.append("String_Node_Str");
    osw.write(buf.toString());
  }
}

Fixed version (ground truth):
/** 
 * Create a list of the found history records.
 * @param history the list of history records to be iterated over.
 * @param osw the output stream writer to write to.
 * @throws IOException if io error occurs
 */
private void printHistoryRecords(List history,OutputStreamWriter osw) throws IOException {
  Iterator iter=history.iterator();
  while (iter.hasNext()) {
    ChecksumHistory historyInfo=(ChecksumHistory)iter.next();
    StringBuffer buf=new StringBuffer(1000);
    buf.append("String_Node_Str");
    buf.append(msg("String_Node_Str")).append("String_Node_Str").append(historyInfo.getBitstreamId()).append("String_Node_Str");
    buf.append(msg("String_Node_Str")).append("String_Node_Str").append(DATE_FORMAT_MAX.format(historyInfo.getProcessStartDate())).append("String_Node_Str");
    buf.append(msg("String_Node_Str")).append("String_Node_Str").append(DATE_FORMAT_MAX.format(historyInfo.getProcessEndDate())).append("String_Node_Str");
    buf.append(msg("String_Node_Str")).append("String_Node_Str").append(historyInfo.getChecksumExpected()).append("String_Node_Str");
    buf.append(msg("String_Node_Str")).append("String_Node_Str").append(historyInfo.getChecksumCalculated()).append("String_Node_Str");
    buf.append(msg("String_Node_Str")).append("String_Node_Str").append(historyInfo.getResult()).append("String_Node_Str");
    buf.append("String_Node_Str");
    osw.write(buf.toString());
  }
}
Program: 3582
Project: 3582
Buggy source:
/** 
 * Slightly convenient method that appends together a msg key and a class name together and retrieves the corresponding message from Messages.properties
 * @param msg final part of message key, omitting fully qualified class name
 * @param classname fully qualified class name.
 * @return Localized message
 */
public String getMessage(String msg,String classname){
  return messages.getString(new StringBuilder(50).append(classname).append("String_Node_Str").append(msg).toString());
}

Fixed version (ground truth):
/** 
 * <p> Convenience method to get localized messages in code. Usage will be of the form: - </p> <pre> I18N.message(&quot;my-key&quot;, this); </pre> <p> N.B. That this method uses the runtime type of the object, and hence should only be used in final classes. </p>
 * @param msg Key for the message, omitting the fully qualified class name
 * @param obj the calling object
 * @return Localized message 
 */
public String getMessage(String msg,Object obj){
  return getMessage(msg,obj.getClass());
}
Program: 3583
Project: 3583
Buggy source:
/** 
 * Return true if an index has changed
 * @param key
 * @return
 * @throws SQLException
 */
public static boolean indexHasChanged(BrowseScope key) throws SQLException {
  Context context=null;
  try {
    context=new Context();
    TableRow results=countAndMax(context,key);
    long count=-1;
    int max=-1;
    if (results != null) {
      count=results.getLongColumn("String_Node_Str");
      max=results.getIntColumn("String_Node_Str");
    }
    context.complete();
    if ((count == getCount(key)) && (max == getMaximum(key))) {
      return false;
    }
    setMaximum(key,max);
    setCount(key,count);
    return true;
  }
 catch (  SQLException sqle) {
    if (context != null) {
      context.abort();
    }
    throw sqle;
  }
}

Fixed version (ground truth):
/** 
 * Return true if an index has changed
 * @param key
 * @return
 * @throws SQLException
 */
public static boolean indexHasChanged(BrowseScope key) throws SQLException {
  Context context=null;
  try {
    context=new Context();
    TableRow results=countAndMax(context,key);
    long count=-1;
    int max=-1;
    if (results != null) {
      if ("String_Node_Str".equals(ConfigurationManager.getProperty("String_Node_Str"))) {
        count=results.getIntColumn("String_Node_Str");
      }
 else {
        count=results.getLongColumn("String_Node_Str");
      }
      max=results.getIntColumn("String_Node_Str");
    }
    context.complete();
    if ((count == getCount(key)) && (max == getMaximum(key))) {
      return false;
    }
    setMaximum(key,max);
    setCount(key,count);
    return true;
  }
 catch (  SQLException sqle) {
    if (context != null) {
      context.abort();
    }
    throw sqle;
  }
}
Program: 3584
Project: 3584
Buggy source:
/** 
 * counts items in this community
 * @return  total items
 */
public int countItems() throws SQLException {
  int collitems=0;
  int commitems=0;
  Collection[] cols=getCollections();
  if (cols.length > 0) {
    for (int j=0; j < cols.length; j++) {
      collitems=cols[j].countItems();
      commitems+=collitems;
    }
  }
  return commitems;
}

Fixed version (ground truth):
/** 
 * counts items in this community
 * @return  total items
 */
public int countItems() throws SQLException {
  int total=0;
  Collection[] cols=getCollections();
  for (int i=0; i < cols.length; i++) {
    total+=cols[i].countItems();
  }
  Community[] comms=getSubcommunities();
  for (int j=0; j < comms.length; j++) {
    total+=comms[j].countItems();
  }
  return total;
}
Program: 3588
Project: 3588
Buggy source:
/** 
 * Set the short description of the bitstream format
 * @param s the new short description
 */
public void setShortDescription(String s) throws SQLException {
  BitstreamFormat unknown=findUnknown(bfContext);
  if (unknown.getID() != getID())   bfRow.setColumn("String_Node_Str",s);
}

Fixed version (ground truth):
/** 
 * Set the short description of the bitstream format
 * @param s the new short description
 */
public void setShortDescription(String s) throws SQLException {
  BitstreamFormat unknown=null;
  ;
  try {
    unknown=findUnknown(bfContext);
  }
 catch (  IllegalStateException e) {
  }
  if (unknown == null || unknown.getID() != getID()) {
    bfRow.setColumn("String_Node_Str",s);
  }
}
Program: 3589
Project: 3589
Buggy source:
private void replaceItems(Context c,Collection[] mycollections,String sourceDir,String mapFile) throws Exception {
  File d=new java.io.File(sourceDir);
  if (d == null) {
    System.out.println("String_Node_Str" + sourceDir);
    System.exit(1);
  }
  Map myhash=readMapFile(mapFile);
  Iterator i=myhash.keySet().iterator();
  ArrayList itemsToDelete=new ArrayList();
  while (i.hasNext()) {
    String newItemName=(String)i.next();
    String oldHandle=(String)myhash.get(newItemName);
    Item oldItem=null;
    Item newItem=null;
    if (oldHandle.indexOf('/') != -1) {
      System.out.println("String_Node_Str" + oldHandle);
      oldItem=(Item)HandleManager.resolveToObject(c,oldHandle);
    }
 else {
      oldItem=Item.find(c,Integer.parseInt(oldHandle));
    }
    newItem=addItem(c,mycollections,sourceDir,newItemName,null);
    itemsToDelete.add(oldItem);
  }
  i=itemsToDelete.iterator();
  while (i.hasNext()) {
    deleteItem(c,(Item)i.next());
  }
}

Fixed version (ground truth):
private void replaceItems(Context c,Collection[] mycollections,String sourceDir,String mapFile) throws Exception {
  File d=new java.io.File(sourceDir);
  if (d == null) {
    System.out.println("String_Node_Str" + sourceDir);
    System.exit(1);
  }
  Map myhash=readMapFile(mapFile);
  Iterator i=myhash.keySet().iterator();
  ArrayList itemsToDelete=new ArrayList();
  while (i.hasNext()) {
    String newItemName=(String)i.next();
    String oldHandle=(String)myhash.get(newItemName);
    Item oldItem=null;
    Item newItem=null;
    if (oldHandle.indexOf('/') != -1) {
      System.out.println("String_Node_Str" + oldHandle);
      oldItem=(Item)HandleManager.resolveToObject(c,oldHandle);
    }
 else {
      oldItem=Item.find(c,Integer.parseInt(oldHandle));
    }
    File handleFile=new File(sourceDir + File.separatorChar + newItemName+ File.separatorChar+ "String_Node_Str");
    PrintWriter handleOut=new PrintWriter(new FileWriter(handleFile,true));
    if (handleOut == null) {
      throw new Exception("String_Node_Str" + handleFile.getCanonicalPath());
    }
    handleOut.println(oldHandle);
    handleOut.close();
    deleteItem(c,oldItem);
    newItem=addItem(c,mycollections,sourceDir,newItemName,null);
  }
}
Program: 3590
Project: 3590
Buggy source:
public String buildHTTPQuery(HttpServletRequest request){
  String querystring="String_Node_Str";
  HashMap queryHash=buildQueryHash(request);
  Iterator i=queryHash.keySet().iterator();
  while (i.hasNext()) {
    String key=(String)i.next();
    String value=(String)queryHash.get(key);
    querystring=querystring + "String_Node_Str" + key+ "String_Node_Str"+ value;
  }
  return (querystring);
}

Fixed version (ground truth):
public String buildHTTPQuery(HttpServletRequest request) throws UnsupportedEncodingException {
  String querystring="String_Node_Str";
  HashMap queryHash=buildQueryHash(request);
  Iterator i=queryHash.keySet().iterator();
  while (i.hasNext()) {
    String key=(String)i.next();
    String value=(String)queryHash.get(key);
    querystring=querystring + "String_Node_Str" + key+ "String_Node_Str"+ URLEncoder.encode(value,Constants.DEFAULT_ENCODING);
  }
  return (querystring);
}
Program: 3593
Project: 3593
Buggy source:
private void getThumbSettings(){
  showThumbs=ConfigurationManager.getBooleanProperty("String_Node_Str");
  if (showThumbs) {
    thumbItemListMaxHeight=ConfigurationManager.getIntProperty("String_Node_Str");
    thumbItemListMaxWidth=ConfigurationManager.getIntProperty("String_Node_Str");
    thumbMaxHeight=ConfigurationManager.getIntProperty("String_Node_Str");
    thumbMaxWidth=ConfigurationManager.getIntProperty("String_Node_Str");
  }
}

Fixed version (ground truth):
private void getThumbSettings(){
  showThumbs=ConfigurationManager.getBooleanProperty("String_Node_Str");
  if (showThumbs) {
    thumbItemListMaxHeight=ConfigurationManager.getIntProperty("String_Node_Str");
    if (thumbItemListMaxHeight == 0) {
      thumbItemListMaxHeight=ConfigurationManager.getIntProperty("String_Node_Str");
    }
    thumbItemListMaxWidth=ConfigurationManager.getIntProperty("String_Node_Str");
    if (thumbItemListMaxWidth == 0) {
      thumbItemListMaxWidth=ConfigurationManager.getIntProperty("String_Node_Str");
    }
  }
}
Program: 3595
Project: 3595
Buggy source:
/** 
 * Write out the AIP for the given item to the given directory. A new directory will be created with the Handle (URL-encoded) as the directory name, and inside, a mets.xml file written, together with the bitstreams.
 * @param context   DSpace context to use
 * @param item      Item to write
 * @param dest      destination directory
 */
public static void writeAIP(Context context,Item item,String dest) throws SQLException, IOException, AuthorizeException, MetsException {
  System.out.println("String_Node_Str" + item.getHandle());
  java.io.File aipDir=new java.io.File(dest + URLEncoder.encode("String_Node_Str" + item.getHandle(),"String_Node_Str"));
  if (!aipDir.mkdir()) {
    throw new IOException("String_Node_Str" + aipDir.toString());
  }
  FileOutputStream out=new FileOutputStream(aipDir.toString() + java.io.File.separator + "String_Node_Str");
  writeMETS(context,item,out);
  out.close();
  Bundle[] bundles=item.getBundles();
  for (int i=0; i < bundles.length; i++) {
    Bitstream[] bitstreams=bundles[i].getBitstreams();
    for (int b=0; b < bitstreams.length; b++) {
      if (bitstreams[b].getFormat().getID() != licenseFormat) {
        out=new FileOutputStream(aipDir.toString() + java.io.File.separator + bitstreams[b].getChecksum());
        InputStream in=bitstreams[b].retrieve();
        Utils.bufferedCopy(in,out);
        out.close();
        in.close();
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Write out the AIP for the given item to the given directory. A new directory will be created with the Handle (URL-encoded) as the directory name, and inside, a mets.xml file written, together with the bitstreams.
 * @param context   DSpace context to use
 * @param item      Item to write
 * @param dest      destination directory
 */
public static void writeAIP(Context context,Item item,String dest) throws SQLException, IOException, AuthorizeException, MetsException {
  System.out.println("String_Node_Str" + item.getHandle());
  java.io.File aipDir=new java.io.File(dest + URLEncoder.encode("String_Node_Str" + item.getHandle(),"String_Node_Str"));
  if (!aipDir.mkdir()) {
    throw new IOException("String_Node_Str" + aipDir.toString());
  }
  FileOutputStream out=new FileOutputStream(aipDir.toString() + java.io.File.separator + "String_Node_Str");
  writeMETS(context,item,out);
  out.close();
  Bundle[] bundles=item.getBundles();
  for (int i=0; i < bundles.length; i++) {
    Bitstream[] bitstreams=bundles[i].getBitstreams();
    for (int b=0; b < bitstreams.length; b++) {
      if (bitstreams[b].getFormat().getID() != licenseFormat && AuthorizeManager.authorizeActionBoolean(context,bitstreams[b],Constants.READ)) {
        out=new FileOutputStream(aipDir.toString() + java.io.File.separator + bitstreams[b].getChecksum());
        InputStream in=bitstreams[b].retrieve();
        Utils.bufferedCopy(in,out);
        out.close();
        in.close();
      }
    }
  }
}
Program: 3596
Project: 3596
Buggy source:
/** 
 * Attempt to filter a bitstream An exception will be thrown if the media filter class cannot be instantiated, exceptions from filtering will be logged to STDOUT and swallowed.
 */
public static void filterBitstream(Context c,Item myItem,Bitstream myBitstream) throws Exception {
  Integer formatID=new Integer(myBitstream.getFormat().getID());
  if (filterNames.containsKey(formatID)) {
    if (!filterCache.containsKey(formatID)) {
      Class f=Class.forName((String)filterNames.get(formatID));
      MediaFilter myFilter=(MediaFilter)f.newInstance();
      filterCache.put(formatID,myFilter);
    }
    MediaFilter myFilter=(MediaFilter)filterCache.get(formatID);
    try {
      myFilter.processBitstream(c,myItem,myBitstream);
      myItem.update();
    }
 catch (    Exception e) {
      System.out.println("String_Node_Str" + myBitstream.getID() + "String_Node_Str"+ e);
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
/** 
 * Attempt to filter a bitstream An exception will be thrown if the media filter class cannot be instantiated, exceptions from filtering will be logged to STDOUT and swallowed.
 */
public static void filterBitstream(Context c,Item myItem,Bitstream myBitstream) throws Exception {
  Integer formatID=new Integer(myBitstream.getFormat().getID());
  if (filterNames.containsKey(formatID)) {
    if (!filterCache.containsKey(formatID)) {
      Class f=Class.forName((String)filterNames.get(formatID));
      MediaFilter myFilter=(MediaFilter)f.newInstance();
      filterCache.put(formatID,myFilter);
    }
    MediaFilter myFilter=(MediaFilter)filterCache.get(formatID);
    try {
      if (myFilter.processBitstream(c,myItem,myBitstream)) {
        myItem.update();
      }
    }
 catch (    Exception e) {
      System.out.println("String_Node_Str" + myBitstream.getID() + "String_Node_Str"+ e);
      e.printStackTrace();
    }
  }
}
Program: 3597
Project: 3597
Buggy source:
/** 
 * Given a contents file and an item, stuffing it with bitstreams from the contents file
 */
private void processContentsFile(Context c,Item i,String path,String filename) throws SQLException, IOException, AuthorizeException {
  String contentspath=path + File.separatorChar + filename;
  String line="String_Node_Str";
  System.out.println("String_Node_Str" + contentspath);
  BufferedReader is=new BufferedReader(new FileReader(contentspath));
  while ((line=is.readLine()) != null) {
    String bundleMarker="String_Node_Str";
    int markerIndex=line.indexOf(bundleMarker);
    if (markerIndex == -1) {
      processContentFileEntry(c,i,path,line,null);
      System.out.println("String_Node_Str" + line);
    }
 else {
      String bundleName=line.substring(markerIndex + bundleMarker.length());
      String bitstreamName=line.substring(0,markerIndex);
      processContentFileEntry(c,i,path,bitstreamName,bundleName);
      System.out.println("String_Node_Str" + bitstreamName + "String_Node_Str"+ bundleName);
    }
  }
  is.close();
}

Fixed version (ground truth):
/** 
 * Given a contents file and an item, stuffing it with bitstreams from the contents file
 */
private void processContentsFile(Context c,Item i,String path,String filename) throws SQLException, IOException, AuthorizeException {
  String contentspath=path + File.separatorChar + filename;
  String line="String_Node_Str";
  System.out.println("String_Node_Str" + contentspath);
  BufferedReader is=new BufferedReader(new FileReader(contentspath));
  while ((line=is.readLine()) != null) {
    if ("String_Node_Str".equals(line.trim()))     continue;
    String bundleMarker="String_Node_Str";
    int markerIndex=line.indexOf(bundleMarker);
    if (markerIndex == -1) {
      processContentFileEntry(c,i,path,line,null);
      System.out.println("String_Node_Str" + line);
    }
 else {
      String bundleName=line.substring(markerIndex + bundleMarker.length());
      String bitstreamName=line.substring(0,markerIndex);
      processContentFileEntry(c,i,path,bitstreamName,bundleName);
      System.out.println("String_Node_Str" + bitstreamName + "String_Node_Str"+ bundleName);
    }
  }
  is.close();
}
Program: 3598
Project: 3598
Buggy source:
private void addDCValue(Item i,Node n) throws TransformerException {
  String value=getStringValue(n);
  String element=getAttributeValue(n,"String_Node_Str");
  String qualifier=getAttributeValue(n,"String_Node_Str");
  String language=getAttributeValue(n,"String_Node_Str");
  System.out.println("String_Node_Str" + element + "String_Node_Str"+ qualifier+ "String_Node_Str"+ value);
  if (qualifier.equals("String_Node_Str"))   qualifier=null;
  if (language.equals("String_Node_Str")) {
    language=ConfigurationManager.getProperty("String_Node_Str");
  }
  if (language == null) {
    language="String_Node_Str";
  }
  i.addDC(element,qualifier,language,value);
}

Fixed version (ground truth):
private void addDCValue(Item i,Node n) throws TransformerException {
  String value=getStringValue(n);
  String element=getAttributeValue(n,"String_Node_Str");
  String qualifier=getAttributeValue(n,"String_Node_Str");
  String language=getAttributeValue(n,"String_Node_Str");
  System.out.println("String_Node_Str" + element + "String_Node_Str"+ qualifier+ "String_Node_Str"+ value);
  if (qualifier.equals("String_Node_Str") || "String_Node_Str".equals(qualifier))   qualifier=null;
  if (language.equals("String_Node_Str")) {
    language=ConfigurationManager.getProperty("String_Node_Str");
  }
  if (language == null) {
    language="String_Node_Str";
  }
  i.addDC(element,qualifier,language,value);
}
Program: 3603
Project: 3603
Buggy source:
/** 
 * Show an item page
 * @param context     Context object
 * @param request     the HTTP request
 * @param response    the HTTP response
 * @param item        the item
 * @param handle      the item's handle
 */
private void displayItem(Context context,HttpServletRequest request,HttpServletResponse response,Item item,String handle) throws ServletException, IOException, SQLException, AuthorizeException {
  if (item.isWithdrawn()) {
    JSPManager.showJSP(request,response,"String_Node_Str");
    return;
  }
  AuthorizeManager.authorizeAction(context,item,Constants.READ);
  log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + handle));
  if (item.canEdit()) {
    request.setAttribute("String_Node_Str",new Boolean(true));
  }
  Collection[] collections=item.getCollections();
  request.setAttribute("String_Node_Str",collections[0]);
  Community[] comms=collections[0].getCommunities();
  request.setAttribute("String_Node_Str",comms[0]);
  request.setAttribute("String_Node_Str",getParents(comms[0],true));
  boolean displayAll=false;
  String modeParam=request.getParameter("String_Node_Str");
  if (modeParam != null && modeParam.equalsIgnoreCase("String_Node_Str")) {
    displayAll=true;
  }
  request.setAttribute("String_Node_Str",new Boolean(displayAll));
  request.setAttribute("String_Node_Str",item);
  request.setAttribute("String_Node_Str",collections);
  JSPManager.showJSP(request,response,"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Show an item page
 * @param context     Context object
 * @param request     the HTTP request
 * @param response    the HTTP response
 * @param item        the item
 * @param handle      the item's handle
 */
private void displayItem(Context context,HttpServletRequest request,HttpServletResponse response,Item item,String handle) throws ServletException, IOException, SQLException, AuthorizeException {
  if (item.isWithdrawn()) {
    JSPManager.showJSP(request,response,"String_Node_Str");
    return;
  }
  AuthorizeManager.authorizeAction(context,item,Constants.READ);
  log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + handle));
  if (item.canEdit()) {
    request.setAttribute("String_Node_Str",new Boolean(true));
  }
  Collection[] collections=item.getCollections();
  request.setAttribute("String_Node_Str",item.getOwningCollection());
  Community[] comms=item.getOwningCollection().getCommunities();
  request.setAttribute("String_Node_Str",comms[0]);
  request.setAttribute("String_Node_Str",getParents(comms[0],true));
  boolean displayAll=false;
  String modeParam=request.getParameter("String_Node_Str");
  if (modeParam != null && modeParam.equalsIgnoreCase("String_Node_Str")) {
    displayAll=true;
  }
  request.setAttribute("String_Node_Str",new Boolean(displayAll));
  request.setAttribute("String_Node_Str",item);
  request.setAttribute("String_Node_Str",collections);
  JSPManager.showJSP(request,response,"String_Node_Str");
}
Program: 3606
Project: 3606
Buggy source:
/** 
 * Give the community a logo.  Passing in <code>null</code> removes any existing logo.  You will need to set the format of the new logo bitstream before it will work, for example to "JPEG".  Note that <code>update(/code> will need to be called for the change to take effect.  Setting a logo and not calling <code>update</code> later may result in a previous logo lying around as an "orphaned" bitstream.
 * @param is   the stream to use as the new logo
 * @return   the new logo bitstream, or <code>null</code> if there is nologo (<code>null</code> was passed in)
 */
public Bitstream setLogo(InputStream is) throws AuthorizeException, IOException, SQLException {
  AuthorizeManager.authorizeAction(ourContext,this,Constants.WRITE);
  if (logo != null) {
    log.info(LogManager.getHeader(ourContext,"String_Node_Str","String_Node_Str" + getID()));
    communityRow.setColumnNull("String_Node_Str");
    logo.delete();
  }
  if (is != null) {
    Bitstream newLogo=Bitstream.create(ourContext,is);
    communityRow.setColumn("String_Node_Str",newLogo.getID());
    logo=newLogo;
    List policies=AuthorizeManager.getPoliciesActionFilter(ourContext,this,Constants.READ);
    AuthorizeManager.addPolicies(ourContext,policies,newLogo);
    log.info(LogManager.getHeader(ourContext,"String_Node_Str","String_Node_Str" + getID() + "String_Node_Str"+ newLogo.getID()));
  }
  return logo;
}

Fixed version (ground truth):
/** 
 * Give the community a logo.  Passing in <code>null</code> removes any existing logo.  You will need to set the format of the new logo bitstream before it will work, for example to "JPEG".  Note that <code>update(/code> will need to be called for the change to take effect.  Setting a logo and not calling <code>update</code> later may result in a previous logo lying around as an "orphaned" bitstream.
 * @param is   the stream to use as the new logo
 * @return   the new logo bitstream, or <code>null</code> if there is nologo (<code>null</code> was passed in)
 */
public Bitstream setLogo(InputStream is) throws AuthorizeException, IOException, SQLException {
  AuthorizeManager.authorizeAction(ourContext,this,Constants.WRITE);
  if (logo != null) {
    log.info(LogManager.getHeader(ourContext,"String_Node_Str","String_Node_Str" + getID()));
    communityRow.setColumnNull("String_Node_Str");
    logo.delete();
    logo=null;
  }
  if (is != null) {
    Bitstream newLogo=Bitstream.create(ourContext,is);
    communityRow.setColumn("String_Node_Str",newLogo.getID());
    logo=newLogo;
    List policies=AuthorizeManager.getPoliciesActionFilter(ourContext,this,Constants.READ);
    AuthorizeManager.addPolicies(ourContext,policies,newLogo);
    log.info(LogManager.getHeader(ourContext,"String_Node_Str","String_Node_Str" + getID() + "String_Node_Str"+ newLogo.getID()));
  }
  return logo;
}
Program: 3608
Project: 3608
Buggy source:
/** 
 * Get the communities this collection appears in
 * @return   array of <code>Community</code> objects
 */
public Community[] getCommunities() throws SQLException {
  TableRowIterator tri=DatabaseManager.query(ourContext,"String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str" + getID() + "String_Node_Str");
  List communities=new ArrayList();
  while (tri.hasNext()) {
    TableRow row=tri.next();
    Community fromCache=(Community)ourContext.fromCache(Community.class,row.getIntColumn("String_Node_Str"));
    if (fromCache != null) {
      communities.add(fromCache);
    }
 else {
      communities.add(new Community(ourContext,row));
    }
  }
  Community[] communityArray=new Community[communities.size()];
  communityArray=(Community[])communities.toArray(communityArray);
  return communityArray;
}

Fixed version (ground truth):
/** 
 * Get the communities this collection appears in
 * @return   array of <code>Community</code> objects
 */
public Community[] getCommunities() throws SQLException {
  TableRowIterator tri=DatabaseManager.query(ourContext,"String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str" + getID() + "String_Node_Str");
  List communities=new ArrayList();
  while (tri.hasNext()) {
    TableRow row=tri.next();
    Community owner=(Community)ourContext.fromCache(Community.class,row.getIntColumn("String_Node_Str"));
    if (owner == null) {
      owner=new Community(ourContext,row);
    }
    communities.add(owner);
    Community[] parents=owner.getAllParents();
    for (int i=0; i < parents.length; i++) {
      communities.add(parents[i]);
    }
  }
  Community[] communityArray=new Community[communities.size()];
  communityArray=(Community[])communities.toArray(communityArray);
  return communityArray;
}
Program: 3609
Project: 3609
Buggy source:
/** 
 * Get the communities this item is in.  Returns an unordered array of the communities that house the collections this item is in.
 * @return  the communities this item is in.
 */
public Community[] getCommunities() throws SQLException {
  List communities=new ArrayList();
  TableRowIterator tri=DatabaseManager.query(ourContext,"String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str" + itemRow.getIntColumn("String_Node_Str") + "String_Node_Str");
  while (tri.hasNext()) {
    TableRow row=tri.next();
    Community fromCache=(Community)ourContext.fromCache(Community.class,row.getIntColumn("String_Node_Str"));
    if (fromCache != null) {
      communities.add(fromCache);
    }
 else {
      communities.add(new Community(ourContext,row));
    }
  }
  Community[] communityArray=new Community[communities.size()];
  communityArray=(Community[])communities.toArray(communityArray);
  return communityArray;
}

Fixed version (ground truth):
/** 
 * Get the communities this item is in.  Returns an unordered array of the communities that house the collections this item is in, including parent communities of the owning collections.
 * @return  the communities this item is in.
 */
public Community[] getCommunities() throws SQLException {
  List communities=new ArrayList();
  TableRowIterator tri=DatabaseManager.query(ourContext,"String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str" + itemRow.getIntColumn("String_Node_Str") + "String_Node_Str");
  while (tri.hasNext()) {
    TableRow row=tri.next();
    Community owner=(Community)ourContext.fromCache(Community.class,row.getIntColumn("String_Node_Str"));
    if (owner == null) {
      owner=new Community(ourContext,row);
    }
    communities.add(owner);
    Community[] parents=owner.getAllParents();
    for (int i=0; i < parents.length; i++) {
      communities.add(parents[i]);
    }
  }
  Community[] communityArray=new Community[communities.size()];
  communityArray=(Community[])communities.toArray(communityArray);
  return communityArray;
}