nus-yam/ex-repair huggingface dataset:
Program: 52244
Project: 52244
Buggy source:
public Map act(Redirector redirector,SourceResolver resolver,Map objectModel,String source,Parameters parameters) throws Exception {
  Map<String,String> map=new HashMap<String,String>();
  String propertyFile=parameters.getParameter("String_Node_Str");
  Properties props=new Properties();
  InputStream in=new FileInputStream(propertyFile);
  props.load(in);
  in.close();
  final String[] parameterNames=parameters.getNames();
  for (int i=0; i < parameterNames.length; i++) {
    final String paramName=parameterNames[i];
    if ("String_Node_Str".equals(paramName)) {
      continue;
    }
    map.put(parameters.getParameter(paramName),props.getProperty(paramName));
  }
  return map;
}

Fixed version (ground truth):
public Map act(Redirector redirector,SourceResolver resolver,Map objectModel,String source,Parameters parameters) throws Exception {
  Map<String,String> map=new HashMap<String,String>();
  String propertyFile=parameters.getParameter("String_Node_Str");
  Properties props=new Properties();
  InputStream in=new FileInputStream(propertyFile);
  try {
    props.load(in);
  }
  finally {
    in.close();
  }
  final String[] parameterNames=parameters.getNames();
  for (int i=0; i < parameterNames.length; i++) {
    final String paramName=parameterNames[i];
    if ("String_Node_Str".equals(paramName)) {
      continue;
    }
    map.put(parameters.getParameter(paramName),props.getProperty(paramName));
  }
  return map;
}
Program: 52248
Project: 52248
Buggy source:
/** 
 * Compare these two activity events based upon the given sort parameter. In the case of a tie, allways fallback to sorting based upon the timestamp.
 */
public int compare(E a,E b){
  if (EventSort.URL == sortBy) {
    String aURL=a.getURL();
    String bURL=b.getURL();
    int cmp=aURL.compareTo(bURL);
    if (cmp != 0)     return cmp;
  }
 else   if (EventSort.AGENT == sortBy) {
    String aAgent=a.getDectectedBrowser();
    String bAgent=b.getDectectedBrowser();
    int cmp=aAgent.compareTo(bAgent);
    if (cmp != 0)     return cmp;
  }
 else   if (EventSort.IP == sortBy) {
    String aIP=a.getIP();
    String bIP=b.getIP();
    int cmp=aIP.compareTo(bIP);
    if (cmp != 0)     return cmp;
  }
 else   if (EventSort.SESSION == sortBy) {
    String aSession=a.getSessionID();
    String bSession=b.getSessionID();
    int cmp=aSession.compareTo(bSession);
    if (cmp != 0)     return cmp;
  }
  if (a.getTimeStamp() > b.getTimeStamp())   return 1;
 else   if (a.getTimeStamp() > b.getTimeStamp())   return -1;
  return 0;
}

Fixed version (ground truth):
/** 
 * Compare these two activity events based upon the given sort parameter. In the case of a tie, allways fallback to sorting based upon the timestamp.
 */
public int compare(E a,E b){
  if (a != null && b == null)   return 1;
 else   if (a == null && b != null)   return -1;
 else   if (a == null && b == null)   return 0;
  if (EventSort.URL == sortBy) {
    String aURL=a.getURL();
    String bURL=b.getURL();
    int cmp=aURL.compareTo(bURL);
    if (cmp != 0)     return cmp;
  }
 else   if (EventSort.AGENT == sortBy) {
    String aAgent=a.getDectectedBrowser();
    String bAgent=b.getDectectedBrowser();
    int cmp=aAgent.compareTo(bAgent);
    if (cmp != 0)     return cmp;
  }
 else   if (EventSort.IP == sortBy) {
    String aIP=a.getIP();
    String bIP=b.getIP();
    int cmp=aIP.compareTo(bIP);
    if (cmp != 0)     return cmp;
  }
 else   if (EventSort.SESSION == sortBy) {
    if (a.getEPersonID() > 0 && b.getEPersonID() < 0)     return 1;
 else     if (a.getEPersonID() < 0 && b.getEPersonID() > 0)     return -1;
    String aSession=a.getSessionID();
    String bSession=b.getSessionID();
    int cmp=aSession.compareTo(bSession);
    if (cmp != 0)     return cmp;
  }
  if (a.getTimeStamp() > b.getTimeStamp())   return 1;
 else   if (a.getTimeStamp() > b.getTimeStamp())   return -1;
  return 0;
}
Program: 52250
Project: 52250
Buggy source:
/** 
 * @return a list of all current events.
 */
public static List<Event> getEvents(){
  List<Event> list=new ArrayList<Event>();
  list.addAll(events);
  return list;
}

Fixed version (ground truth):
/** 
 * @return a list of all current events.
 */
public static List<Event> getEvents(){
  List<Event> list=new ArrayList<Event>();
synchronized (events) {
    list.addAll(events);
  }
  return list;
}
Program: 52251
Project: 52251
Buggy source:
/** 
 * Record this current event.
 */
public Map act(Redirector redirector,SourceResolver resolver,Map objectModel,String source,Parameters parameters) throws Exception {
  Request request=ObjectModelHelper.getRequest(objectModel);
  Context context=ContextUtil.obtainContext(objectModel);
  Event event=new Event(context,request);
  events.add(event);
  while (events.size() > MAX_EVENTS)   events.poll();
  return null;
}

Fixed version (ground truth):
/** 
 * Record this current event.
 */
public Map act(Redirector redirector,SourceResolver resolver,Map objectModel,String source,Parameters parameters) throws Exception {
  Request request=ObjectModelHelper.getRequest(objectModel);
  Context context=ContextUtil.obtainContext(objectModel);
synchronized (events) {
    Event event=new Event(context,request);
    events.add(event);
    while (events.size() > MAX_EVENTS)     events.poll();
  }
  return null;
}
Program: 52254
Project: 52254
Buggy source:
/** 
 * Get the file size of the export archive represented by the file name
 * @param fileName name of the file to get the size
 * @param eperson the eperson requesting file
 * @return
 * @throws Exception
 */
public static long getExportFileSize(String fileName) throws Exception {
  String strID=fileName.substring(fileName.lastIndexOf('_') + 1,fileName.lastIndexOf('.'));
  File file=new File(getExportDownloadDirectory(Integer.parseInt(strID)) + System.getProperty("String_Node_Str") + fileName);
  if (!file.exists() || !file.isFile()) {
    throw new FileNotFoundException("String_Node_Str" + getExportDownloadDirectory(Integer.parseInt(strID)) + System.getProperty("String_Node_Str")+ fileName+ "String_Node_Str");
  }
  return file.length();
}

Fixed version (ground truth):
/** 
 * Get the file size of the export archive represented by the file name
 * @param fileName name of the file to get the size
 * @return
 * @throws Exception
 */
public static long getExportFileSize(String fileName) throws Exception {
  String strID=fileName.substring(fileName.lastIndexOf('_') + 1,fileName.lastIndexOf('.'));
  File file=new File(getExportDownloadDirectory(Integer.parseInt(strID)) + System.getProperty("String_Node_Str") + fileName);
  if (!file.exists() || !file.isFile()) {
    throw new FileNotFoundException("String_Node_Str" + getExportDownloadDirectory(Integer.parseInt(strID)) + System.getProperty("String_Node_Str")+ fileName+ "String_Node_Str");
  }
  return file.length();
}
Program: 52255
Project: 52255
Buggy source:
/** 
 * Since the archive is created in a new thread we are unable to communicate with calling method about success or failure. We accomplis this communication with email instead. Send an error email if the export archive fails
 * @param toMail -email to send message to
 * @param fromMail -email for the from field
 * @param ccMail -carbon copy email
 * @param fileName -the file name to be downloaded. It is added to the url in the email
 * @throws MessagingException
 */
public static void emailErrorMessage(String toMail,String fromMail,String ccMail,String error) throws MessagingException {
  StringBuffer content=new StringBuffer();
  content.append("String_Node_Str");
  content.append(System.getProperty("String_Node_Str"));
  content.append(System.getProperty("String_Node_Str"));
  content.append("String_Node_Str");
  content.append(System.getProperty("String_Node_Str"));
  content.append(System.getProperty("String_Node_Str"));
  content.append("String_Node_Str");
  content.append(error);
  content.append(System.getProperty("String_Node_Str"));
  content.append(System.getProperty("String_Node_Str"));
  content.append("String_Node_Str");
  sendMessage(toMail,fromMail,ccMail,"String_Node_Str",content);
}

Fixed version (ground truth):
/** 
 * Since the archive is created in a new thread we are unable to communicate with calling method about success or failure. We accomplis this communication with email instead. Send an error email if the export archive fails
 * @param toMail -email to send message to
 * @param fromMail -email for the from field
 * @param ccMail -carbon copy email
 * @param error -the error message
 * @throws MessagingException
 */
public static void emailErrorMessage(String toMail,String fromMail,String ccMail,String error) throws MessagingException {
  StringBuffer content=new StringBuffer();
  content.append("String_Node_Str");
  content.append(System.getProperty("String_Node_Str"));
  content.append(System.getProperty("String_Node_Str"));
  content.append("String_Node_Str");
  content.append(System.getProperty("String_Node_Str"));
  content.append(System.getProperty("String_Node_Str"));
  content.append("String_Node_Str");
  content.append(error);
  content.append(System.getProperty("String_Node_Str"));
  content.append(System.getProperty("String_Node_Str"));
  content.append("String_Node_Str");
  sendMessage(toMail,fromMail,ccMail,"String_Node_Str",content);
}
Program: 52256
Project: 52256
Buggy source:
/** 
 * Decode the given string from URL transmission.
 * @param encodedString The encoded string.
 * @return The unencoded string
 */
public static String URLDecode(String encodedString) throws UIException {
  if (encodedString == null)   return null;
  try {
    return URLDecoder.decode(encodedString,Constants.DEFAULT_ENCODING);
  }
 catch (  UnsupportedEncodingException uee) {
    throw new UIException(uee);
  }
}

Fixed version (ground truth):
/** 
 * Decode the given string from URL transmission.
 * @param encodedString The encoded string.
 * @return The unencoded string
 */
public static String URLDecode(String encodedString) throws UIException {
  if (encodedString == null)   return null;
  try {
    if (encodedString.contains("String_Node_Str")) {
      encodedString=encodedString.replace("String_Node_Str","String_Node_Str");
    }
    return URLDecoder.decode(encodedString,Constants.DEFAULT_ENCODING);
  }
 catch (  UnsupportedEncodingException uee) {
    throw new UIException(uee);
  }
}
Program: 52257
Project: 52257
Buggy source:
/** 
 * Since the archive is created in a new thread we are unable to communicate with calling method about success or failure. We accomplis this communication with email instead. Send a success email once the export archive is complete and ready for download
 * @param toMail - email to send message to
 * @param fromMail - email for the from field
 * @param ccMail - carbon copy email
 * @param fileName - the file name to be downloaded. It is added to the url in the email
 * @throws MessagingException
 */
public static void emailSuccessMessage(String toMail,String fromMail,String ccMail,String fileName) throws MessagingException {
  StringBuffer content=new StringBuffer();
  content.append("String_Node_Str");
  content.append(System.getProperty("String_Node_Str"));
  content.append(System.getProperty("String_Node_Str"));
  content.append("String_Node_Str");
  content.append(System.getProperty("String_Node_Str"));
  content.append(ConfigurationManager.getProperty("String_Node_Str"));
  content.append("String_Node_Str");
  content.append(fileName);
  content.append(System.getProperty("String_Node_Str"));
  content.append(System.getProperty("String_Node_Str"));
  content.append("String_Node_Str");
  content.append(ConfigurationManager.getProperty("String_Node_Str"));
  content.append("String_Node_Str");
  content.append(System.getProperty("String_Node_Str"));
  content.append(System.getProperty("String_Node_Str"));
  content.append("String_Node_Str");
  sendMessage(toMail,fromMail,ccMail,"String_Node_Str",content);
}

Fixed version (ground truth):
/** 
 * Since the archive is created in a new thread we are unable to communicate with calling method about success or failure. We accomplis this communication with email instead. Send a success email once the export archive is complete and ready for download
 * @param context - the current Context
 * @param eperson - eperson to send the email to
 * @param fileName - the file name to be downloaded. It is added to the url in the email
 * @throws MessagingException
 */
public static void emailSuccessMessage(Context context,EPerson eperson,String fileName) throws MessagingException {
  try {
    Locale supportedLocale=I18nUtil.getEPersonLocale(eperson);
    Email email=ConfigurationManager.getEmail(I18nUtil.getEmailFilename(supportedLocale,"String_Node_Str"));
    email.addRecipient(eperson.getEmail());
    email.addArgument(ConfigurationManager.getProperty("String_Node_Str") + "String_Node_Str" + fileName);
    email.addArgument(ConfigurationManager.getProperty("String_Node_Str"));
    email.send();
  }
 catch (  Exception e) {
    log.warn(LogManager.getHeader(context,"String_Node_Str","String_Node_Str"),e);
  }
}
Program: 52258
Project: 52258
Buggy source:
public void run(){
  Context context;
  ItemIterator iitems=null;
  try {
    context=new Context();
    context.setIgnoreAuthorization(true);
    iitems=new ItemIterator(context,items);
    String fileName=assembleFileName("String_Node_Str",eperson,new Date());
    String workDir=getExportWorkDirectory() + System.getProperty("String_Node_Str") + fileName;
    String downloadDir=getExportDownloadDirectory(eperson.getID());
    File wkDir=new File(workDir);
    if (!wkDir.exists()) {
      wkDir.mkdirs();
    }
    File dnDir=new File(downloadDir);
    if (!dnDir.exists()) {
      dnDir.mkdirs();
    }
    exportItem(context,iitems,workDir,1);
    zip(workDir,downloadDir + System.getProperty("String_Node_Str") + fileName+ "String_Node_Str");
    emailSuccessMessage(eperson.getEmail(),ConfigurationManager.getProperty("String_Node_Str"),additionalEmail,fileName + "String_Node_Str");
    context.setIgnoreAuthorization(false);
  }
 catch (  Exception e1) {
    try {
      emailErrorMessage(eperson.getEmail(),ConfigurationManager.getProperty("String_Node_Str"),additionalEmail,e1.getMessage());
    }
 catch (    Exception e) {
    }
    throw new RuntimeException(e1);
  }
 finally {
    if (iitems != null)     iitems.close();
  }
}

Fixed version (ground truth):
public void run(){
  Context context;
  ItemIterator iitems=null;
  try {
    context=new Context();
    context.setIgnoreAuthorization(true);
    iitems=new ItemIterator(context,items);
    String fileName=assembleFileName("String_Node_Str",eperson,new Date());
    String workDir=getExportWorkDirectory() + System.getProperty("String_Node_Str") + fileName;
    String downloadDir=getExportDownloadDirectory(eperson.getID());
    File wkDir=new File(workDir);
    if (!wkDir.exists()) {
      wkDir.mkdirs();
    }
    File dnDir=new File(downloadDir);
    if (!dnDir.exists()) {
      dnDir.mkdirs();
    }
    exportItem(context,iitems,workDir,1);
    zip(workDir,downloadDir + System.getProperty("String_Node_Str") + fileName+ "String_Node_Str");
    emailSuccessMessage(context,eperson,fileName + "String_Node_Str");
    context.setIgnoreAuthorization(false);
  }
 catch (  Exception e1) {
    try {
      emailErrorMessage(eperson,e1.getMessage());
    }
 catch (    Exception e) {
    }
    throw new RuntimeException(e1);
  }
 finally {
    if (iitems != null)     iitems.close();
  }
}
Program: 52260
Project: 52260
Buggy source:
/** 
 * Since the archive is created in a new thread we are unable to communicate with calling method about success or failure. We accomplis this communication with email instead. Send an error email if the export archive fails
 * @param toMail - email to send message to
 * @param fromMail - email for the from field
 * @param ccMail - carbon copy email
 * @param error - the error message
 * @throws MessagingException
 */
public static void emailErrorMessage(String toMail,String fromMail,String ccMail,String error) throws MessagingException {
  StringBuffer content=new StringBuffer();
  content.append("String_Node_Str");
  content.append(System.getProperty("String_Node_Str"));
  content.append(System.getProperty("String_Node_Str"));
  content.append("String_Node_Str");
  content.append(System.getProperty("String_Node_Str"));
  content.append(System.getProperty("String_Node_Str"));
  content.append("String_Node_Str");
  content.append(error);
  content.append(System.getProperty("String_Node_Str"));
  content.append(System.getProperty("String_Node_Str"));
  content.append("String_Node_Str");
  sendMessage(toMail,fromMail,ccMail,"String_Node_Str",content);
}

Fixed version (ground truth):
/** 
 * Since the archive is created in a new thread we are unable to communicate with calling method about success or failure. We accomplis this communication with email instead. Send an error email if the export archive fails
 * @param eperson - EPerson to send the error message to
 * @param error - the error message
 * @throws MessagingException
 */
public static void emailErrorMessage(EPerson eperson,String error) throws MessagingException {
  log.warn("String_Node_Str" + error);
  try {
    Locale supportedLocale=I18nUtil.getEPersonLocale(eperson);
    Email email=ConfigurationManager.getEmail(I18nUtil.getEmailFilename(supportedLocale,"String_Node_Str"));
    email.addRecipient(eperson.getEmail());
    email.addArgument(error);
    email.addArgument(ConfigurationManager.getProperty("String_Node_Str") + "String_Node_Str");
    email.send();
  }
 catch (  Exception e) {
    log.warn("String_Node_Str",e);
  }
}
Program: 52261
Project: 52261
Buggy source:
public void run(){
  Context context;
  ItemIterator iitems=null;
  try {
    context=new Context();
    context.setIgnoreAuthorization(true);
    iitems=new ItemIterator(context,items);
    String fileName=assembleFileName("String_Node_Str",eperson,new Date());
    String workDir=getExportWorkDirectory() + System.getProperty("String_Node_Str") + fileName;
    String downloadDir=getExportDownloadDirectory(eperson.getID());
    File wkDir=new File(workDir);
    if (!wkDir.exists()) {
      wkDir.mkdirs();
    }
    File dnDir=new File(downloadDir);
    if (!dnDir.exists()) {
      dnDir.mkdirs();
    }
    exportItem(context,iitems,workDir,1);
    zip(workDir,downloadDir + System.getProperty("String_Node_Str") + fileName+ "String_Node_Str");
    emailSuccessMessage(context,eperson,fileName + "String_Node_Str");
    context.setIgnoreAuthorization(false);
  }
 catch (  Exception e1) {
    try {
      emailErrorMessage(eperson,e1.getMessage());
    }
 catch (    Exception e) {
    }
    throw new RuntimeException(e1);
  }
 finally {
    if (iitems != null)     iitems.close();
  }
}

Fixed version (ground truth):
public void run(){
  Context context=null;
  ItemIterator iitems=null;
  try {
    context=new Context();
    context.setIgnoreAuthorization(true);
    iitems=new ItemIterator(context,items);
    String fileName=assembleFileName("String_Node_Str",eperson,new Date());
    String workDir=getExportWorkDirectory() + System.getProperty("String_Node_Str") + fileName;
    String downloadDir=getExportDownloadDirectory(eperson.getID());
    File wkDir=new File(workDir);
    if (!wkDir.exists()) {
      wkDir.mkdirs();
    }
    File dnDir=new File(downloadDir);
    if (!dnDir.exists()) {
      dnDir.mkdirs();
    }
    exportItem(context,iitems,workDir,1);
    zip(workDir,downloadDir + System.getProperty("String_Node_Str") + fileName+ "String_Node_Str");
    emailSuccessMessage(context,eperson,fileName + "String_Node_Str");
    context.setIgnoreAuthorization(false);
  }
 catch (  Exception e1) {
    try {
      emailErrorMessage(eperson,e1.getMessage());
    }
 catch (    Exception e) {
    }
    throw new RuntimeException(e1);
  }
 finally {
    if (iitems != null)     iitems.close();
    try {
      context.complete();
    }
 catch (    SQLException sqle) {
      context.abort();
    }
  }
}
Program: 52263
Project: 52263
Buggy source:
/** 
 * Get repeated values from a form. If "foo" is passed in as the parameter, values in the form of parameters "foo", "foo_1", "foo_2", etc. are returned. <P> This method can also handle "composite fields" (metadata fields which may require multiple params, etc. a first name and last name).
 * @param request the HTTP request containing the form information
 * @param metadataField the metadata field which can store repeated values
 * @param param the repeated parameter on the page (used to fill out the metadataField)
 * @return a List of Strings
 */
protected List getRepeatedParameter(HttpServletRequest request,String metadataField,String param){
  List vals=new LinkedList();
  int i=0;
  boolean foundLast=false;
  log.debug("String_Node_Str" + metadataField + "String_Node_Str"+ metadataField);
  while (!foundLast) {
    String s=null;
    if (i == 0)     s=request.getParameter(param);
 else     s=request.getParameter(param + "String_Node_Str" + i);
    if (s != null) {
      boolean addValue=true;
      String[] selected=request.getParameterValues(metadataField + "String_Node_Str");
      if (selected != null) {
        for (int j=0; j < selected.length; j++) {
          if (selected[j].equals(metadataField + "String_Node_Str" + i)) {
            addValue=false;
          }
        }
      }
      if (addValue)       vals.add(s.trim());
    }
 else {
      foundLast=true;
    }
    i++;
  }
  return vals;
}

Fixed version (ground truth):
/** 
 * Get repeated values from a form. If "foo" is passed in as the parameter, values in the form of parameters "foo", "foo_1", "foo_2", etc. are returned. <P> This method can also handle "composite fields" (metadata fields which may require multiple params, etc. a first name and last name).
 * @param request the HTTP request containing the form information
 * @param metadataField the metadata field which can store repeated values
 * @param param the repeated parameter on the page (used to fill out the metadataField)
 * @return a List of Strings
 */
protected List getRepeatedParameter(HttpServletRequest request,String metadataField,String param){
  List vals=new LinkedList();
  int i=1;
  boolean foundLast=false;
  log.debug("String_Node_Str" + metadataField + "String_Node_Str"+ metadataField);
  while (!foundLast) {
    String s=null;
    s=request.getParameter(param + "String_Node_Str" + i);
    if (s == null) {
      s=request.getParameter(param);
      foundLast=true;
    }
    if (s != null) {
      boolean addValue=true;
      String[] selected=request.getParameterValues(metadataField + "String_Node_Str");
      if (selected != null) {
        for (int j=0; j < selected.length; j++) {
          if (selected[j].equals(metadataField + "String_Node_Str" + i)) {
            addValue=false;
          }
        }
      }
      if (addValue)       vals.add(s.trim());
    }
    i++;
  }
  return vals;
}
Program: 52264
Project: 52264
Buggy source:
/** 
 * What to add at the end of the body 
 */
public void addBody(Body body) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException {
  if (this.bodyEmpty) {
    Division notFound=body.addDivision("String_Node_Str","String_Node_Str");
    notFound.setHead(T_head);
    notFound.addPara(T_para1);
    notFound.addPara().addXref(contextPath,T_go_home);
  }
}

Fixed version (ground truth):
/** 
 * What to add at the end of the body 
 */
public void addBody(Body body) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException {
  if (this.bodyEmpty) {
    Division notFound=body.addDivision("String_Node_Str","String_Node_Str");
    notFound.setHead(T_head);
    notFound.addPara(T_para1);
    notFound.addPara().addXref(contextPath,T_go_home);
    HttpServletResponse response=(HttpServletResponse)objectModel.get(HttpEnvironment.HTTP_RESPONSE_OBJECT);
    response.setStatus(HttpServletResponse.SC_NOT_FOUND);
  }
}
Program: 52265
Project: 52265
Buggy source:
/** 
 * Get repeated values from a form. If "foo" is passed in as the parameter, values in the form of parameters "foo", "foo_1", "foo_2", etc. are returned. <P> This method can also handle "composite fields" (metadata fields which may require multiple params, etc. a first name and last name).
 * @param request the HTTP request containing the form information
 * @param metadataField the metadata field which can store repeated values
 * @param param the repeated parameter on the page (used to fill out the metadataField)
 * @return a List of Strings
 */
protected List getRepeatedParameter(HttpServletRequest request,String metadataField,String param){
  List vals=new LinkedList();
  int i=0;
  boolean foundLast=false;
  log.debug("String_Node_Str" + metadataField + "String_Node_Str"+ metadataField);
  while (!foundLast) {
    String s=null;
    if (i == 0)     s=request.getParameter(param);
 else     s=request.getParameter(param + "String_Node_Str" + i);
    if (s != null) {
      boolean addValue=true;
      String[] selected=request.getParameterValues(metadataField + "String_Node_Str");
      if (selected != null) {
        for (int j=0; j < selected.length; j++) {
          if (selected[j].equals(metadataField + "String_Node_Str" + i)) {
            addValue=false;
          }
        }
      }
      if (addValue)       vals.add(s.trim());
    }
 else {
      foundLast=true;
    }
    i++;
  }
  return vals;
}

Fixed version (ground truth):
/** 
 * Get repeated values from a form. If "foo" is passed in as the parameter, values in the form of parameters "foo", "foo_1", "foo_2", etc. are returned. <P> This method can also handle "composite fields" (metadata fields which may require multiple params, etc. a first name and last name).
 * @param request the HTTP request containing the form information
 * @param metadataField the metadata field which can store repeated values
 * @param param the repeated parameter on the page (used to fill out the metadataField)
 * @return a List of Strings
 */
protected List getRepeatedParameter(HttpServletRequest request,String metadataField,String param){
  List vals=new LinkedList();
  int i=1;
  boolean foundLast=false;
  log.debug("String_Node_Str" + metadataField + "String_Node_Str"+ metadataField);
  while (!foundLast) {
    String s=null;
    s=request.getParameter(param + "String_Node_Str" + i);
    if (s == null) {
      s=request.getParameter(param);
      foundLast=true;
    }
    if (s != null) {
      boolean addValue=true;
      String[] selected=request.getParameterValues(metadataField + "String_Node_Str");
      if (selected != null) {
        for (int j=0; j < selected.length; j++) {
          if (selected[j].equals(metadataField + "String_Node_Str" + i)) {
            addValue=false;
          }
        }
      }
      if (addValue)       vals.add(s.trim());
    }
    i++;
  }
  return vals;
}
Program: 52267
Project: 52267
Buggy source:
/** 
 * Decode the given string from URL transmission.
 * @param encodedString The encoded string.
 * @return The unencoded string
 */
public static String URLDecode(String encodedString) throws UIException {
  if (encodedString == null)   return null;
  try {
    return URLDecoder.decode(encodedString,Constants.DEFAULT_ENCODING);
  }
 catch (  UnsupportedEncodingException uee) {
    throw new UIException(uee);
  }
}

Fixed version (ground truth):
/** 
 * Decode the given string from URL transmission.
 * @param encodedString The encoded string.
 * @return The unencoded string
 */
public static String URLDecode(String encodedString) throws UIException {
  if (encodedString == null)   return null;
  try {
    if (encodedString.contains("String_Node_Str")) {
      encodedString=encodedString.replace("String_Node_Str","String_Node_Str");
    }
    return URLDecoder.decode(encodedString,Constants.DEFAULT_ENCODING);
  }
 catch (  UnsupportedEncodingException uee) {
    throw new UIException(uee);
  }
}
Program: 52270
Project: 52270
Buggy source:
private boolean itemsChanged(Context context,DSpaceObject dso,long timeStamp) throws SQLException {
  DCDate dcStartDate=new DCDate(new Date(timeStamp));
  DCDate dcEndDate=new DCDate(new Date(System.currentTimeMillis()));
  String startDate=dcStartDate.toString().substring(0,10);
  String endDate=dcEndDate.toString().substring(0,10);
  try {
    return (Harvest.harvest(context,dso,startDate,endDate,0,1,false,false,false).size() > 0);
  }
 catch (  ParseException pe) {
    return false;
  }
}

Fixed version (ground truth):
private boolean itemsChanged(Context context,DSpaceObject dso,long timeStamp) throws SQLException {
  DCDate dcStartDate=new DCDate(new Date(timeStamp));
  DCDate dcEndDate=new DCDate(new Date(System.currentTimeMillis()));
  String startDate=dcStartDate.toString().substring(0,10);
  String endDate=dcEndDate.toString().substring(0,10);
  try {
    boolean includeAll=ConfigurationManager.getBooleanProperty("String_Node_Str",true);
    return (Harvest.harvest(context,dso,startDate,endDate,0,1,false,false,false,includeAll).size() > 0);
  }
 catch (  ParseException pe) {
    return false;
  }
}
Program: 52275
Project: 52275
Buggy source:
public boolean canDisseminate(DSpaceObject dso){
  return true;
}

Fixed version (ground truth):
public boolean canDisseminate(DSpaceObject dso){
  if (dso.getType() == Constants.BITSTREAM)   return true;
 else   return false;
}
Program: 52276
Project: 52276
Buggy source:
public boolean canDisseminate(DSpaceObject dso){
  return true;
}

Fixed version (ground truth):
public boolean canDisseminate(DSpaceObject dso){
  if (dso.getType() == Constants.BITSTREAM)   return true;
 else   return false;
}
Program: 52277
Project: 52277
Buggy source:
/** 
 * add group to this group
 * @param g
 */
public void addMember(Group g){
  loadData();
  if (isMember(g)) {
    return;
  }
  groups.add(g);
  groupsChanged=true;
  myContext.addEvent(new Event(Event.ADD,Constants.GROUP,getID(),Constants.GROUP,g.getID(),g.getName()));
}

Fixed version (ground truth):
/** 
 * add group to this group
 * @param g
 */
public void addMember(Group g){
  loadData();
  if (isMember(g) || getID() == g.getID()) {
    return;
  }
  groups.add(g);
  groupsChanged=true;
  myContext.addEvent(new Event(Event.ADD,Constants.GROUP,getID(),Constants.GROUP,g.getID(),g.getName()));
}
Program: 52278
Project: 52278
Buggy source:
/** 
 * Close the context, without committing any of the changes performed using this context. The database connection is freed. No exception is thrown if there is an error freeing the database connection, since this method may be called as part of an error-handling routine where an SQLException has already been thrown.
 */
public void abort(){
  try {
    connection.rollback();
  }
 catch (  SQLException se) {
    log.error(se.getMessage());
    se.printStackTrace();
  }
 finally {
    DatabaseManager.freeConnection(connection);
    connection=null;
    events=null;
  }
}

Fixed version (ground truth):
/** 
 * Close the context, without committing any of the changes performed using this context. The database connection is freed. No exception is thrown if there is an error freeing the database connection, since this method may be called as part of an error-handling routine where an SQLException has already been thrown.
 */
public void abort(){
  try {
    if (!connection.isClosed())     connection.rollback();
  }
 catch (  SQLException se) {
    log.error(se.getMessage());
    se.printStackTrace();
  }
 finally {
    try {
      if (!connection.isClosed())       DatabaseManager.freeConnection(connection);
    }
 catch (    Exception ex) {
      ex.printStackTrace();
    }
    connection=null;
    events=null;
  }
}
Program: 52279
Project: 52279
Buggy source:
static String checkEmptyQuery(String myquery){
  if (myquery.equals("String_Node_Str")) {
    myquery="String_Node_Str";
  }
  return myquery;
}

Fixed version (ground truth):
static String checkEmptyQuery(String myquery){
  if (myquery == null || myquery.equals("String_Node_Str") || myquery.equals("String_Node_Str")) {
    myquery="String_Node_Str";
  }
  return myquery;
}
Program: 52280
Project: 52280
Buggy source:
/** 
 * Set the DSpace context to use
 * @param context
 */
public void setContext(Context context){
  this.context=context;
}

Fixed version (ground truth):
/** 
 * Set the DSpace context to use
 * @param context the context
 */
public void setContext(Context context){
  this.context=context;
}
Program: 52281
Project: 52281
Buggy source:
public int[] getSpecialGroups(Context context,HttpServletRequest request){
  if ((context.getCurrentUser() != null) && (!context.getCurrentUser().getNetid().equals("String_Node_Str"))) {
    if (ldapGroup == null) {
      log.warn(LogManager.getHeader(context,"String_Node_Str","String_Node_Str"));
      return new int[0];
    }
 else {
      return new int[]{ldapGroup.getID()};
    }
  }
  return new int[0];
}

Fixed version (ground truth):
public int[] getSpecialGroups(Context context,HttpServletRequest request){
  try {
    if (!context.getCurrentUser().getNetid().equals("String_Node_Str")) {
      if (ldapGroup == null) {
        log.warn(LogManager.getHeader(context,"String_Node_Str","String_Node_Str"));
        return new int[0];
      }
 else {
        return new int[]{ldapGroup.getID()};
      }
    }
  }
 catch (  NullPointerException npe) {
  }
  return new int[0];
}
Program: 52282
Project: 52282
Buggy source:
/** 
 * Generate the validity for this cached entry
 * @return
 */
public SourceValidity getValidity(){
  if (validity == null) {
    try {
      initialise();
      boolean showReport=ConfigurationManager.getBooleanProperty("String_Node_Str");
      if (!showReport) {
        try {
          showReport=AuthorizeManager.isAdmin(context);
        }
 catch (        SQLException sqle) {
          log.error("String_Node_Str",sqle);
        }
      }
      if (showReport) {
        File analysisFile=null;
        if (reportDate != null)         analysisFile=StatisticsLoader.getAnalysisFor(reportDate);
 else         analysisFile=StatisticsLoader.getGeneralAnalysis();
        if (analysisFile != null) {
          DSpaceValidity newValidity=new DSpaceValidity();
          newValidity.add(Long.toString(analysisFile.lastModified()));
          newValidity.add("String_Node_Str");
          newValidity.add(Long.toString(analysisFile.length()));
          validity=newValidity.complete();
        }
      }
    }
 catch (    Exception e) {
    }
  }
  return validity;
}

Fixed version (ground truth):
/** 
 * Generate the validity for this cached entry
 * @return
 */
public SourceValidity getValidity(){
  if (validity == null) {
    try {
      initialise();
      boolean showReport=ConfigurationManager.getBooleanProperty("String_Node_Str");
      if (!showReport) {
        showReport=AuthorizeManager.isAdmin(context);
      }
      if (showReport) {
        File analysisFile=null;
        if (reportDate != null)         analysisFile=StatisticsLoader.getAnalysisFor(reportDate);
 else         analysisFile=StatisticsLoader.getGeneralAnalysis();
        if (analysisFile != null) {
          DSpaceValidity newValidity=new DSpaceValidity();
          newValidity.add(Long.toString(analysisFile.lastModified()));
          newValidity.add("String_Node_Str");
          newValidity.add(Long.toString(analysisFile.length()));
          validity=newValidity.complete();
        }
      }
    }
 catch (    Exception e) {
    }
  }
  return validity;
}
Program: 52283
Project: 52283
Buggy source:
/** 
 * Attempt to authenticate the user. 
 */
public Map act(Redirector redirector,SourceResolver resolver,Map objectModel,String source,Parameters parameters) throws Exception {
  Request request=ObjectModelHelper.getRequest(objectModel);
  String email=request.getParameter("String_Node_Str");
  String password=request.getParameter("String_Node_Str");
  String realm=request.getParameter("String_Node_Str");
  if (email == null)   email="String_Node_Str";
  if (password == null)   password="String_Node_Str";
  try {
    Context context=AuthenticationUtil.Authenticate(objectModel,email,password,realm);
    EPerson eperson=context.getCurrentUser();
    if (eperson != null) {
      String redirectURL=request.getContextPath();
      if (AuthenticationUtil.isInterupptedRequest(objectModel)) {
        redirectURL+=AuthenticationUtil.resumeInterruptedRequest(objectModel);
      }
 else {
        String loginRedirect=ConfigurationManager.getProperty("String_Node_Str");
        redirectURL+=(loginRedirect != null) ? loginRedirect.trim() : "String_Node_Str";
      }
      final HttpServletResponse httpResponse=(HttpServletResponse)objectModel.get(HttpEnvironment.HTTP_RESPONSE_OBJECT);
      httpResponse.sendRedirect(redirectURL);
      context.setCurrentUser(null);
      return new HashMap();
    }
  }
 catch (  SQLException sqle) {
    throw new PatternException("String_Node_Str",sqle);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Attempt to authenticate the user. 
 */
public Map act(Redirector redirector,SourceResolver resolver,Map objectModel,String source,Parameters parameters) throws Exception {
  Request request=ObjectModelHelper.getRequest(objectModel);
  String email=request.getParameter("String_Node_Str");
  String password=request.getParameter("String_Node_Str");
  String realm=request.getParameter("String_Node_Str");
  if ((email == null) || (password == null)) {
    return null;
  }
  try {
    Context context=AuthenticationUtil.Authenticate(objectModel,email,password,realm);
    EPerson eperson=context.getCurrentUser();
    if (eperson != null) {
      String redirectURL=request.getContextPath();
      if (AuthenticationUtil.isInterupptedRequest(objectModel)) {
        redirectURL+=AuthenticationUtil.resumeInterruptedRequest(objectModel);
      }
 else {
        String loginRedirect=ConfigurationManager.getProperty("String_Node_Str");
        redirectURL+=(loginRedirect != null) ? loginRedirect.trim() : "String_Node_Str";
      }
      final HttpServletResponse httpResponse=(HttpServletResponse)objectModel.get(HttpEnvironment.HTTP_RESPONSE_OBJECT);
      httpResponse.sendRedirect(redirectURL);
      context.setCurrentUser(null);
      return new HashMap();
    }
  }
 catch (  SQLException sqle) {
    throw new PatternException("String_Node_Str",sqle);
  }
  return null;
}
Program: 52285
Project: 52285
Buggy source:
public int[] getSpecialGroups(Context context,HttpServletRequest request){
  try {
    if (!context.getCurrentUser().getNetid().equals("String_Node_Str")) {
      if (ldapGroup == null) {
        log.warn(LogManager.getHeader(context,"String_Node_Str","String_Node_Str"));
        return new int[0];
      }
 else {
        return new int[]{ldapGroup.getID()};
      }
    }
  }
 catch (  NullPointerException npe) {
  }
  return new int[0];
}

Fixed version (ground truth):
public int[] getSpecialGroups(Context context,HttpServletRequest request){
  try {
    if (!context.getCurrentUser().getNetid().equals("String_Node_Str")) {
      String groupName=ConfigurationManager.getProperty("String_Node_Str");
      if ((groupName != null) && (!groupName.trim().equals("String_Node_Str"))) {
        ldapGroup=Group.findByName(new Context(),groupName);
        if (ldapGroup == null) {
          log.warn(LogManager.getHeader(context,"String_Node_Str","String_Node_Str"));
          return new int[0];
        }
 else {
          return new int[]{ldapGroup.getID()};
        }
      }
    }
  }
 catch (  Exception npe) {
  }
  return new int[0];
}
Program: 52286
Project: 52286
Buggy source:
/** 
 * Add a single link to the view item page that allows the user  to submit to the collection.
 */
public void addBody(Body body) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException {
  DSpaceObject dso=HandleUtil.obtainHandle(objectModel);
  if (!(dso instanceof Collection))   return;
  Collection collection=(Collection)dso;
  if (AuthorizeManager.authorizeActionBoolean(context,collection,Constants.ADD)) {
    Division home=body.addDivision("String_Node_Str","String_Node_Str");
    Division viewer=home.addDivision("String_Node_Str","String_Node_Str");
    String submitURL=contextPath + "String_Node_Str" + collection.getHandle()+ "String_Node_Str";
    viewer.addPara().addXref(submitURL,"String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Add a single link to the view item page that allows the user  to submit to the collection.
 */
public void addBody(Body body) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException {
  DSpaceObject dso=HandleUtil.obtainHandle(objectModel);
  if (!(dso instanceof Collection))   return;
  Collection collection=(Collection)dso;
  if (AuthorizeManager.authorizeActionBoolean(context,collection,Constants.ADD)) {
    Division home=body.addDivision("String_Node_Str","String_Node_Str");
    Division viewer=home.addDivision("String_Node_Str","String_Node_Str");
    String submitURL=contextPath + "String_Node_Str" + collection.getHandle()+ "String_Node_Str";
    viewer.addPara().addXref(submitURL,T_submit);
  }
}
Program: 52288
Project: 52288
Buggy source:
/** 
 * Do the beginning of a Step. First do pre-processing, then display the JSP (if there is one). If there's no JSP, just End the step immediately.
 * @param context current DSpace context
 * @param request current servlet request object
 * @param response current servlet response object
 * @param subInfo submission info object
 * @return true if the step is completed (no JSP was loaded), falseotherwise
 */
private boolean doStepStart(Context context,HttpServletRequest request,HttpServletResponse response,SubmissionInfo subInfo) throws ServletException, IOException, SQLException, AuthorizeException {
  log.debug("String_Node_Str" + this.getClass().getName());
  stepJSPUI.doPreProcessing(context,request,response,subInfo);
  if (!response.isCommitted()) {
    log.debug("String_Node_Str" + this.getClass().getName());
    int errorFlag=stepProcessing.doProcessing(context,request,response,subInfo);
    if (errorFlag != AbstractProcessingStep.STATUS_COMPLETE) {
      String errorMessage=stepProcessing.getErrorMessage(errorFlag);
      if (errorMessage == null) {
        errorMessage="String_Node_Str" + this.getClass().getName() + "String_Node_Str"+ errorFlag+ "String_Node_Str"+ "String_Node_Str";
      }
      log.error(errorMessage);
    }
    return completeStep(context,request,response,subInfo);
  }
 else   return false;
}

Fixed version (ground truth):
/** 
 * Do the beginning of a Step. First do pre-processing, then display the JSP (if there is one). If there's no JSP, just End the step immediately.
 * @param context current DSpace context
 * @param request current servlet request object
 * @param response current servlet response object
 * @param subInfo submission info object
 * @return true if the step is completed (no JSP was loaded), falseotherwise
 */
private boolean doStepStart(Context context,HttpServletRequest request,HttpServletResponse response,SubmissionInfo subInfo) throws ServletException, IOException, SQLException, AuthorizeException {
  log.debug("String_Node_Str" + this.getClass().getName());
  if (stepJSPUI != null)   stepJSPUI.doPreProcessing(context,request,response,subInfo);
  if (!response.isCommitted()) {
    log.debug("String_Node_Str" + this.getClass().getName());
    int errorFlag=stepProcessing.doProcessing(context,request,response,subInfo);
    if (errorFlag != AbstractProcessingStep.STATUS_COMPLETE) {
      String errorMessage=stepProcessing.getErrorMessage(errorFlag);
      if (errorMessage == null) {
        errorMessage="String_Node_Str" + this.getClass().getName() + "String_Node_Str"+ errorFlag+ "String_Node_Str"+ "String_Node_Str";
      }
      log.error(errorMessage);
    }
    return completeStep(context,request,response,subInfo);
  }
 else   return false;
}
Program: 52289
Project: 52289
Buggy source:
/** 
 * Initialize the current JSPStepManager object, by loading the  specified step class.
 * @param stepConfig the SubmissionStepConfig object which describes this step's configuration in the item-submission.xml
 * @throws Exception if the JSPStep cannot be loaded or the class specified doesn't implement the JSPStep interface
 */
public static JSPStepManager loadStep(SubmissionStepConfig stepConfig) throws Exception {
  JSPStepManager stepManager=new JSPStepManager();
  stepManager.stepConfig=stepConfig;
  ClassLoader loader=stepManager.getClass().getClassLoader();
  Class stepClass=loader.loadClass(stepConfig.getProcessingClassName());
  Object stepInstance=stepClass.newInstance();
  if (stepInstance instanceof AbstractProcessingStep) {
    stepManager.stepProcessing=(AbstractProcessingStep)stepClass.newInstance();
  }
 else {
    throw new Exception("String_Node_Str" + stepConfig.getProcessingClassName() + "String_Node_Str"+ "String_Node_Str");
  }
  stepClass=loader.loadClass(stepConfig.getJSPUIClassName());
  stepInstance=stepClass.newInstance();
  if (stepInstance instanceof JSPStep) {
    stepManager.stepJSPUI=(JSPStep)stepClass.newInstance();
  }
 else {
    throw new Exception("String_Node_Str" + stepConfig.getJSPUIClassName() + "String_Node_Str"+ "String_Node_Str");
  }
  return stepManager;
}

Fixed version (ground truth):
/** 
 * Initialize the current JSPStepManager object, by loading the  specified step class.
 * @param stepConfig the SubmissionStepConfig object which describes this step's configuration in the item-submission.xml
 * @throws Exception if the JSPStep cannot be loaded or the class specified doesn't implement the JSPStep interface
 */
public static JSPStepManager loadStep(SubmissionStepConfig stepConfig) throws Exception {
  JSPStepManager stepManager=new JSPStepManager();
  stepManager.stepConfig=stepConfig;
  ClassLoader loader=stepManager.getClass().getClassLoader();
  Class stepClass=loader.loadClass(stepConfig.getProcessingClassName());
  Object stepInstance=stepClass.newInstance();
  if (stepInstance instanceof AbstractProcessingStep) {
    stepManager.stepProcessing=(AbstractProcessingStep)stepClass.newInstance();
  }
 else {
    throw new Exception("String_Node_Str" + stepConfig.getProcessingClassName() + "String_Node_Str"+ "String_Node_Str");
  }
  if (stepConfig.getJSPUIClassName() != null && stepConfig.getJSPUIClassName().length() > 0) {
    stepClass=loader.loadClass(stepConfig.getJSPUIClassName());
    stepInstance=stepClass.newInstance();
    if (stepInstance instanceof JSPStep) {
      stepManager.stepJSPUI=(JSPStep)stepClass.newInstance();
    }
 else {
      throw new Exception("String_Node_Str" + stepConfig.getJSPUIClassName() + "String_Node_Str"+ "String_Node_Str");
    }
  }
  return stepManager;
}
Program: 52291
Project: 52291
Buggy source:
/** 
 * Generate the cache validity object. The validity object will include the item being viewed, along with all bundles & bitstreams.
 */
public SourceValidity getValidity(){
  DSpaceObject dso=null;
  if (this.validity == null) {
    try {
      dso=URIUtil.resolve(objectModel);
      DSpaceValidity validity=new DSpaceValidity();
      validity.add(dso);
      this.validity=validity.complete();
    }
 catch (    Exception e) {
    }
    log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + (dso == null ? "String_Node_Str" : dso.getHandle())));
  }
  return this.validity;
}

Fixed version (ground truth):
/** 
 * Generate the cache validity object. The validity object will include the item being viewed, along with all bundles & bitstreams.
 */
public SourceValidity getValidity(){
  DSpaceObject dso=null;
  if (this.validity == null) {
    try {
      dso=URIUtil.resolve(objectModel);
      DSpaceValidity validity=new DSpaceValidity();
      validity.add(dso);
      this.validity=validity.complete();
    }
 catch (    Exception e) {
    }
    log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + (dso == null ? "String_Node_Str" : IdentifierService.getCanonicalForm(dso))));
  }
  return this.validity;
}