nus-yam/ex-repair huggingface dataset:
Program: 90102
Project: 90102
Buggy source:
/** 
 * Get the URI from this request. In contrast to javax.servlet.HttpServletResponse this includes the query string.
 * @return The URI from this request.
 * @throws IOFailure if the URI is invalid. This should never happen.
 */
public URI getURI(){
  try {
    if (hr.getQueryString() != null) {
      return new URI(hr.getRequestURL().toString() + "String_Node_Str" + hr.getQueryString());
    }
 else {
      return new URI(hr.getRequestURL().toString());
    }
  }
 catch (  URISyntaxException e) {
    throw new IOFailure("String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Get the URI from this request. In contrast to javax.servlet.HttpServletResponse this includes the query string.
 * @return The URI from this request.
 * @throws IOFailure if the URI is invalid. This should never happen.
 */
public URI getURI(){
  String uri_string;
  if (hr.getQueryString() != null) {
    uri_string=hr.getRequestURL().toString() + "String_Node_Str" + uriEncode(hr.getQueryString());
  }
 else {
    uri_string=hr.getRequestURL().toString();
  }
  try {
    return new URI(uri_string);
  }
 catch (  URISyntaxException e) {
    throw new IOFailure("String_Node_Str" + uri_string + "String_Node_Str",e);
  }
}
Program: 90103
Project: 90103
Buggy source:
public void setUp() throws Exception {
  rs.setUp();
  JMSConnectionTestMQ.useJMSConnectionTestMQ();
  super.setUp();
}

Fixed version (ground truth):
public void setUp() throws Exception {
  rs.setUp();
  JMSConnectionTestMQ.useJMSConnectionTestMQ();
  Settings.set(CommonSettings.ENVIRONMENT_LOCATION_NAMES,"String_Node_Str","String_Node_Str");
  if (!Location.isKnownLocation("String_Node_Str") || !Location.isKnownLocation("String_Node_Str")) {
    fail("String_Node_Str");
  }
  super.setUp();
}
Program: 90105
Project: 90105
Buggy source:
/** 
 * Return a description of where an object is used otherwhere in the database, or null.
 * @param select A select statement finding the names of other uses.  Thestatement should result in exactly one column of string values.
 * @param victim The object being used.
 * @param args Any objects that may be used to prepare the select statement.
 * @return A string describing the usages, or null if no usages were found.
 */
public static String getUsages(String select,Object victim,Object... args){
  Connection c=DBConnect.getDBConnection();
  PreparedStatement s=null;
  try {
    s=prepareStatement(c,select,args);
    ResultSet res=s.executeQuery();
    if (res.next()) {
      List<String> used_in=new ArrayList<String>();
      do {
        used_in.add(res.getString(1));
      }
 while (res.next());
      return used_in.toString();
    }
    return null;
  }
 catch (  SQLException e) {
    final String message="String_Node_Str" + victim;
    log.warn(message,e);
    throw new IOFailure(message,e);
  }
 finally {
    closeStatementIfOpen(s);
  }
}

Fixed version (ground truth):
/** 
 * Return a description of where an object is used elsewhere in the database, or null.
 * @param select A select statement finding the names of other uses.  Thestatement should result in exactly one column of string values.
 * @param victim The object being used.
 * @param args Any objects that may be used to prepare the select statement.
 * @return A string describing the usages, or null if no usages were found.
 */
public static String getUsages(String select,Object victim,Object... args){
  Connection c=DBConnect.getDBConnection();
  PreparedStatement s=null;
  try {
    s=prepareStatement(c,select,args);
    ResultSet res=s.executeQuery();
    if (res.next()) {
      List<String> usedIn=new ArrayList<String>();
      do {
        usedIn.add(res.getString(1));
      }
 while (res.next());
      return usedIn.toString();
    }
    return null;
  }
 catch (  SQLException e) {
    final String message="String_Node_Str" + victim;
    log.warn(message,e);
    throw new IOFailure(message,e);
  }
 finally {
    closeStatementIfOpen(s);
  }
}
Program: 90106
Project: 90106
Buggy source:
/** 
 * Set the CLOB maxlength. If contents.length() > maxSize, contents is truncated to contain the first maxSize characters of the contents, and a warning is logged.
 * @param s a prepared statement
 * @param fieldNum the field-index, where the contents are inserted
 * @param contents the contents
 * @param maxSize the maxsize for this contents
 * @param o the Object, which assumedly have a field named fieldName
 * @param fieldName a given field (Assumedly in Object o)
 * @throws SQLException
 */
public static void setClobMaxLength(PreparedStatement s,int fieldNum,String contents,long maxSize,Object o,String fieldName) throws SQLException {
  if (contents != null) {
    if (contents.length() > maxSize) {
      log.warn(fieldName + "String_Node_Str" + o+ "String_Node_Str"+ maxSize+ "String_Node_Str"+ maxSize+ "String_Node_Str"+ contents);
      if (maxSize > Integer.MAX_VALUE) {
        maxSize=Integer.MAX_VALUE;
      }
      contents=contents.substring(0,(int)maxSize);
    }
    s.setCharacterStream(fieldNum,new StringReader(contents),contents.length());
    s.setString(fieldNum,contents);
  }
 else {
    s.setNull(fieldNum,Types.CLOB);
  }
}

Fixed version (ground truth):
/** 
 * Set the CLOB maxlength. If contents.length() > maxSize, contents is truncated to contain the first maxSize characters of the contents, and a warning is logged.
 * @param s a prepared statement
 * @param fieldNum the field-index, where the contents are inserted
 * @param contents the contents
 * @param maxSize the maxsize for this contents
 * @param o the Object, which assumedly have a field named fieldName
 * @param fieldName a given field (Assumedly in Object o)
 * @throws SQLException
 */
public static void setClobMaxLength(PreparedStatement s,int fieldNum,String contents,long maxSize,Object o,String fieldName) throws SQLException {
  if (contents != null) {
    if (contents.length() > maxSize) {
      log.warn(fieldName + "String_Node_Str" + o+ "String_Node_Str"+ maxSize+ "String_Node_Str"+ "String_Node_Str"+ maxSize+ "String_Node_Str"+ contents);
      if (maxSize > Integer.MAX_VALUE) {
        maxSize=Integer.MAX_VALUE;
      }
      contents=contents.substring(0,(int)maxSize);
    }
    s.setCharacterStream(fieldNum,new StringReader(contents),contents.length());
    s.setString(fieldNum,contents);
  }
 else {
    s.setNull(fieldNum,Types.CLOB);
  }
}
Program: 90107
Project: 90107
Buggy source:
/** 
 * Check whether an object is used elsewhere in the database.
 * @param select A select statement finding the names of other uses.  Thestatement should result in exactly one column of string values.
 * @param victim The object being used.
 * @param args Any objects that may be used to prepare the select statement.
 * @throws PermissionDenied if the object has usages.
 */
public static void checkForUses(String select,Object victim,Object... args){
  String usages=DBUtils.getUsages(select,victim,args);
  if (usages != null) {
    String message="String_Node_Str" + victim + "String_Node_Str"+ usages;
    throw new PermissionDenied(message);
  }
  Connection c=DBConnect.getDBConnection();
  PreparedStatement s=null;
  try {
    s=prepareStatement(c,select,args);
    ResultSet res=s.executeQuery();
    if (res.next()) {
      List<String> used_in=new ArrayList<String>();
      do {
        used_in.add(res.getString(1));
      }
 while (res.next());
    }
  }
 catch (  SQLException e) {
    final String message="String_Node_Str" + victim;
    log.warn(message,e);
    throw new IOFailure(message,e);
  }
 finally {
    closeStatementIfOpen(s);
  }
}

Fixed version (ground truth):
/** 
 * Check whether an object is used elsewhere in the database.
 * @param select A select statement finding the names of other uses.  Thestatement should result in exactly one column of string values.
 * @param victim The object being used.
 * @param args Any objects that may be used to prepare the select statement.
 * @throws PermissionDenied if the object has usages.
 */
public static void checkForUses(String select,Object victim,Object... args){
  String usages=DBUtils.getUsages(select,victim,args);
  if (usages != null) {
    String message="String_Node_Str" + victim + "String_Node_Str"+ usages;
    throw new PermissionDenied(message);
  }
  Connection c=DBConnect.getDBConnection();
  PreparedStatement s=null;
  try {
    s=prepareStatement(c,select,args);
    ResultSet res=s.executeQuery();
    if (res.next()) {
      List<String> usedIn=new ArrayList<String>();
      do {
        usedIn.add(res.getString(1));
      }
 while (res.next());
    }
  }
 catch (  SQLException e) {
    final String message="String_Node_Str" + victim;
    log.warn(message,e);
    throw new IOFailure(message,e);
  }
 finally {
    closeStatementIfOpen(s);
  }
}
Program: 90108
Project: 90108
Buggy source:
/** 
 * Accept 1 to 4 parameters and checks them for validity.
 * @param args the arguments
 * @return true, if given arguments are validreturns false otherwise
 */
public boolean checkArgs(String... args){
  if (args.length < 1) {
    System.err.println("String_Node_Str");
    return false;
  }
  if (args.length > 4) {
    System.err.println("String_Node_Str");
    return false;
  }
  if (!new File(args[0]).canRead()) {
    System.err.println("String_Node_Str" + args[0] + "String_Node_Str");
    return false;
  }
  if (args.length > 1) {
    try {
      Pattern.compile(args[1]);
    }
 catch (    PatternSyntaxException e) {
      System.err.println("String_Node_Str" + args[1] + "String_Node_Str");
      return false;
    }
  }
  if (args.length > 2 && !Location.isKnownLocation(args[2])) {
    System.err.println("String_Node_Str" + args[2] + "String_Node_Str"+ Location.getKnown());
    return false;
  }
  if (args.length > 3 && !new File(args[3]).canWrite()) {
    System.err.println("String_Node_Str" + args[3] + "String_Node_Str");
    return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Accept 1 to 4 parameters and checks them for validity.
 * @param args the arguments
 * @return true, if given arguments are validreturns false otherwise
 */
public boolean checkArgs(String... args){
  if (args.length < 1) {
    System.err.println("String_Node_Str");
    return false;
  }
  if (args.length > 4) {
    System.err.println("String_Node_Str");
    return false;
  }
  if (!new File(args[0]).canRead()) {
    System.err.println("String_Node_Str" + args[0] + "String_Node_Str");
    return false;
  }
  if (args.length > 1) {
    try {
      Pattern.compile(args[1]);
    }
 catch (    PatternSyntaxException e) {
      System.err.println("String_Node_Str" + args[1] + "String_Node_Str");
      return false;
    }
  }
  if (args.length > 2 && !Location.isKnownLocation(args[2])) {
    System.err.println("String_Node_Str" + args[2] + "String_Node_Str"+ Location.getKnown());
    return false;
  }
  if (args.length > 3) {
    if (new File(args[3]).exists()) {
      System.err.println("String_Node_Str" + args[3] + "String_Node_Str");
      return false;
    }
 else {
      try {
        File tmpFile=new File(args[3]);
        tmpFile.createNewFile();
        if (!tmpFile.canWrite()) {
          System.err.println("String_Node_Str" + args[3] + "String_Node_Str");
          return false;
        }
      }
 catch (      IOException e) {
        System.err.println("String_Node_Str" + args[3] + "String_Node_Str");
        return false;
      }
    }
  }
  return true;
}
Program: 90110
Project: 90110
Buggy source:
/** 
 * Process the report by a bitarchive that a file was correctly uploaded. 1. Update the upload, and store states appropriately 2. Verify that data are correctly stored in the archive by running a batch job on the archived file to perform a MD5 checksum comparison 3. Check if store operation is completed and update admin data if so
 * @param arcfileName The arcfile that was uploaded
 * @param bitarchiveName The bitarchive that uploaded it
 */
synchronized private void processDataUploaded(String arcfileName,String bitarchiveName){
  log.debug("String_Node_Str" + arcfileName + "String_Node_Str"+ bitarchiveName);
  ad.setState(arcfileName,bitarchiveName,BitArchiveStoreState.DATA_UPLOADED);
  sendChecksumJob(arcfileName,connectedBitarchives.get(bitarchiveName));
}

Fixed version (ground truth):
/** 
 * Process the report by a bitarchive that a file was correctly uploaded. 1. Update the upload, and store states appropriately 2. Verify that data are correctly stored in the archive by running a batch job on the archived file to perform a MD5 checksum comparison 3. Check if store operation is completed and update admin data if so
 * @param arcfileName The arcfile that was uploaded
 * @param bitarchiveName The bitarchive that uploaded it
 */
private synchronized void processDataUploaded(String arcfileName,String bitarchiveName){
  log.debug("String_Node_Str" + arcfileName + "String_Node_Str"+ bitarchiveName);
  ad.setState(arcfileName,bitarchiveName,BitArchiveStoreState.DATA_UPLOADED);
  sendChecksumJob(arcfileName,connectedBitarchives.get(bitarchiveName));
}
Program: 90111
Project: 90111
Buggy source:
/** 
 * Test whether the current state is such that we may send a reply for the file we are currently processing, and send the reply if it is. We reply only when there is an outstanding message to reply to, and a) The file is reported complete in all bitarchives or b) No bitarchive has outstanding reply messages AND some bitarchive has reported failure.
 * @param arcFileName The arcfile we consider replying to.
 */
synchronized private void considerReplyingOnStore(String arcFileName){
  if (ad.hasReplyInfo(arcFileName)) {
    if (isStoreCompleted(arcFileName)) {
      replyOK(arcFileName,ad.removeReplyInfo(arcFileName));
    }
 else     if (oneBitArchiveHasFailed(arcFileName) && noBitArchiveInStateUploadStarted(arcFileName)) {
      replyNotOK(arcFileName,ad.removeReplyInfo(arcFileName));
    }
  }
}

Fixed version (ground truth):
/** 
 * Test whether the current state is such that we may send a reply for the file we are currently processing, and send the reply if it is. We reply only when there is an outstanding message to reply to, and a) The file is reported complete in all bitarchives or b) No bitarchive has outstanding reply messages AND some bitarchive has reported failure.
 * @param arcFileName The arcfile we consider replying to.
 */
private synchronized void considerReplyingOnStore(String arcFileName){
  if (ad.hasReplyInfo(arcFileName)) {
    if (isStoreCompleted(arcFileName)) {
      replyOK(arcFileName,ad.removeReplyInfo(arcFileName));
    }
 else     if (oneBitArchiveHasFailed(arcFileName) && noBitArchiveInStateUploadStarted(arcFileName)) {
      replyNotOK(arcFileName,ad.removeReplyInfo(arcFileName));
    }
  }
}
Program: 90112
Project: 90112
Buggy source:
/** 
 * Sanity check for data consistency in the construction of the ArcRepository, specifically that the number of ALL_BA, ANY_BA, and THE_BAMON queues are all equal to the number of credentials.
 * @param allBas The topics for bitarchives
 * @param anyBas The queues for biatarchives
 * @param theBamons The queues for biatrchive monitors
 * @throws PermissionDenied if inconsistent data is found
 */
private void checkChannels(ChannelID[] allBas,ChannelID[] anyBas,ChannelID[] theBamons) throws PermissionDenied {
  if (theBamons.length != allBas.length || theBamons.length != anyBas.length) {
    StringBuilder values=new StringBuilder("String_Node_Str" + "String_Node_Str");
    values.append("String_Node_Str");
    values.append(Arrays.toString(allBas));
    values.append("String_Node_Str");
    values.append(Arrays.toString(anyBas));
    values.append("String_Node_Str");
    values.append(Arrays.toString(theBamons));
    throw new PermissionDenied(values.toString());
  }
}

Fixed version (ground truth):
/** 
 * Sanity check for data consistency in the construction of the ArcRepository, specifically that the number of ALL_BA, ANY_BA, and THE_BAMON queues are all equal to the number of credentials.
 * @param allBas The topics for bitarchives
 * @param anyBas The queues for bitarchives
 * @param theBamons The queues for bitarchive monitors
 * @throws PermissionDenied if inconsistent data is found
 */
private void checkChannels(ChannelID[] allBas,ChannelID[] anyBas,ChannelID[] theBamons) throws PermissionDenied {
  if (theBamons.length != allBas.length || theBamons.length != anyBas.length) {
    StringBuilder values=new StringBuilder("String_Node_Str" + "String_Node_Str");
    values.append("String_Node_Str");
    values.append(Arrays.toString(allBas));
    values.append("String_Node_Str");
    values.append(Arrays.toString(anyBas));
    values.append("String_Node_Str");
    values.append(Arrays.toString(theBamons));
    throw new PermissionDenied(values.toString());
  }
}
Program: 90114
Project: 90114
Buggy source:
/** 
 * Stores a file in all known Bitarchives. This runs asynchronously, and returns immediately. Sideeffects: 1) The RemoteFile added to List outstandingRemoteFiles 2) TODO: Document other sideeffects.
 * @param rf A remotefile to be stored.
 * @param replyInfo A StoreMessage used to reply with succes or failure.
 * @throws IOFailure If file couldn't be stores.
 */
synchronized public void store(RemoteFile rf,StoreMessage replyInfo) throws IOFailure {
  final String filename=rf.getName();
  log.info("String_Node_Str" + filename + "String_Node_Str");
  outstandingRemoteFiles.put(filename,rf);
  if (ad.hasEntry(filename)) {
    if (!rf.getChecksum().equals(ad.getCheckSum(filename))) {
      String msg="String_Node_Str" + filename + "String_Node_Str"+ "String_Node_Str"+ ad.getCheckSum(filename)+ "String_Node_Str"+ rf.getChecksum();
      log.warn(msg);
      replyNotOK(filename,replyInfo);
      return;
    }
    log.debug("String_Node_Str" + filename + "String_Node_Str"+ "String_Node_Str"+ isStoreCompleted(filename));
    ad.setReplyInfo(filename,replyInfo);
  }
 else {
    ad.addEntry(filename,replyInfo,rf.getChecksum());
  }
  for (  Map.Entry<String,BitarchiveClient> entry : connectedBitarchives.entrySet()) {
    startUpload(rf,entry.getValue(),entry.getKey());
  }
  considerReplyingOnStore(filename);
}

Fixed version (ground truth):
/** 
 * Stores a file in all known Bitarchives. This runs asynchronously, and returns immediately. Side effects: 1) The RemoteFile added to List outstandingRemoteFiles 2) TODO: Document other side effects.
 * @param rf A remotefile to be stored.
 * @param replyInfo A StoreMessage used to reply with success or failure.
 * @throws IOFailure If file couldn't be stores.
 */
public synchronized void store(RemoteFile rf,StoreMessage replyInfo) throws IOFailure {
  final String filename=rf.getName();
  log.info("String_Node_Str" + filename + "String_Node_Str");
  outstandingRemoteFiles.put(filename,rf);
  if (ad.hasEntry(filename)) {
    if (!rf.getChecksum().equals(ad.getCheckSum(filename))) {
      String msg="String_Node_Str" + filename + "String_Node_Str"+ "String_Node_Str"+ ad.getCheckSum(filename)+ "String_Node_Str"+ rf.getChecksum();
      log.warn(msg);
      replyNotOK(filename,replyInfo);
      return;
    }
    log.debug("String_Node_Str" + filename + "String_Node_Str"+ "String_Node_Str"+ isStoreCompleted(filename));
    ad.setReplyInfo(filename,replyInfo);
  }
 else {
    ad.addEntry(filename,replyInfo,rf.getChecksum());
  }
  for (  Map.Entry<String,BitarchiveClient> entry : connectedBitarchives.entrySet()) {
    startUpload(rf,entry.getValue(),entry.getKey());
  }
  considerReplyingOnStore(filename);
}
Program: 90115
Project: 90115
Buggy source:
/** 
 * Initiate uploading of file to a specific bitarchive. The corresponding upload record in admin data is created.
 * @param rf remotefile to upload to bitarchive.
 * @param bitarchiveClient The bitarchive client to upload to.
 * @param bitarchiveName The name of the bitarchive, where RemoteFile is to be stored.
 */
synchronized private void startUpload(RemoteFile rf,BitarchiveClient bitarchiveClient,String bitarchiveName){
  final String filename=rf.getName();
  log.debug("String_Node_Str" + filename + "String_Node_Str"+ bitarchiveName+ "String_Node_Str");
  if (!ad.hasState(filename,bitarchiveName)) {
    ad.setState(filename,bitarchiveName,BitArchiveStoreState.UPLOAD_STARTED);
    bitarchiveClient.upload(rf);
  }
 else {
    BitArchiveStoreState storeState=ad.getState(filename,bitarchiveName);
    log.trace("String_Node_Str" + storeState);
switch (storeState) {
case UPLOAD_FAILED:
case UPLOAD_STARTED:
case DATA_UPLOADED:
      if (storeState == BitArchiveStoreState.UPLOAD_FAILED) {
        ad.setState(filename,bitarchiveName,BitArchiveStoreState.UPLOAD_STARTED);
      }
    sendChecksumJob(filename,bitarchiveClient);
  break;
case UPLOAD_COMPLETED:
break;
default :
throw new UnknownID("String_Node_Str" + storeState + "String_Node_Str");
}
}
}

Fixed version (ground truth):
/** 
 * Initiate uploading of file to a specific bitarchive. The corresponding upload record in admin data is created.
 * @param rf remotefile to upload to bitarchive.
 * @param bitarchiveClient The bitarchive client to upload to.
 * @param bitarchiveName The name of the bitarchive, where RemoteFile is to be stored.
 */
private synchronized void startUpload(RemoteFile rf,BitarchiveClient bitarchiveClient,String bitarchiveName){
  final String filename=rf.getName();
  log.debug("String_Node_Str" + filename + "String_Node_Str"+ bitarchiveName+ "String_Node_Str");
  if (!ad.hasState(filename,bitarchiveName)) {
    ad.setState(filename,bitarchiveName,BitArchiveStoreState.UPLOAD_STARTED);
    bitarchiveClient.upload(rf);
  }
 else {
    BitArchiveStoreState storeState=ad.getState(filename,bitarchiveName);
    log.trace("String_Node_Str" + storeState);
switch (storeState) {
case UPLOAD_FAILED:
case UPLOAD_STARTED:
case DATA_UPLOADED:
      if (storeState == BitArchiveStoreState.UPLOAD_FAILED) {
        ad.setState(filename,bitarchiveName,BitArchiveStoreState.UPLOAD_STARTED);
      }
    sendChecksumJob(filename,bitarchiveClient);
  break;
case UPLOAD_COMPLETED:
break;
default :
throw new UnknownID("String_Node_Str" + storeState + "String_Node_Str");
}
}
}
Program: 90116
Project: 90116
Buggy source:
/** 
 * Reply to a store message with status Not Ok.
 * @param arcFileName The file for which we are replying
 * @param msg The message to reply to
 */
synchronized private void replyNotOK(String arcFileName,StoreMessage msg){
  outstandingRemoteFiles.remove(arcFileName);
  clearRetries(arcFileName);
  msg.setNotOk("String_Node_Str" + arcFileName);
  log.warn("String_Node_Str" + arcFileName + "String_Node_Str");
  log.debug("String_Node_Str" + msg + "String_Node_Str");
  con.reply(msg);
}

Fixed version (ground truth):
/** 
 * Reply to a store message with status Not Ok.
 * @param arcFileName The file for which we are replying
 * @param msg The message to reply to
 */
private synchronized void replyNotOK(String arcFileName,StoreMessage msg){
  outstandingRemoteFiles.remove(arcFileName);
  clearRetries(arcFileName);
  msg.setNotOk("String_Node_Str" + arcFileName);
  log.warn("String_Node_Str" + arcFileName + "String_Node_Str");
  log.debug("String_Node_Str" + msg + "String_Node_Str");
  con.reply(msg);
}
Program: 90117
Project: 90117
Buggy source:
/** 
 * Event handler for upload messages reporting the upload result. Checks the success status of the upload and updates admin data accordingly
 * @param msg an UploadMessage
 */
synchronized public void onUpload(UploadMessage msg){
  log.debug("String_Node_Str" + msg.toString());
  ArgumentNotValid.checkNotNull(msg,"String_Node_Str");
  String bitarchiveName=resolveBitarchiveID(msg.getTo().getName());
  if (msg.isOk()) {
    processDataUploaded(msg.getArcfileName(),bitarchiveName);
  }
 else {
    processUploadFailed(msg.getArcfileName(),bitarchiveName);
  }
}

Fixed version (ground truth):
/** 
 * Event handler for upload messages reporting the upload result. Checks the success status of the upload and updates admin data accordingly
 * @param msg an UploadMessage
 */
public synchronized void onUpload(UploadMessage msg){
  ArgumentNotValid.checkNotNull(msg,"String_Node_Str");
  log.debug("String_Node_Str" + msg.toString());
  String bitarchiveName=resolveBitarchiveID(msg.getTo().getName());
  if (msg.isOk()) {
    processDataUploaded(msg.getArcfileName(),bitarchiveName);
  }
 else {
    processUploadFailed(msg.getArcfileName(),bitarchiveName);
  }
}
Program: 90118
Project: 90118
Buggy source:
/** 
 * Reply to a store message with status Ok.
 * @param arcFileName The file for which we are replying
 * @param msg The message to reply to
 */
synchronized private void replyOK(String arcFileName,StoreMessage msg){
  outstandingRemoteFiles.remove(arcFileName);
  clearRetries(arcFileName);
  log.info("String_Node_Str" + arcFileName + "String_Node_Str");
  log.debug("String_Node_Str" + msg + "String_Node_Str");
  con.reply(msg);
}

Fixed version (ground truth):
/** 
 * Reply to a store message with status Ok.
 * @param arcFileName The file for which we are replying
 * @param msg The message to reply to
 */
private synchronized void replyOK(String arcFileName,StoreMessage msg){
  outstandingRemoteFiles.remove(arcFileName);
  clearRetries(arcFileName);
  log.info("String_Node_Str" + arcFileName + "String_Node_Str");
  log.debug("String_Node_Str" + msg + "String_Node_Str");
  con.reply(msg);
}
Program: 90119
Project: 90119
Buggy source:
/** 
 * Connects to the given host, and lists all mbeans matching the query. For each of these mbeans, registers a proxymbean, that on any invocation will connect to the remote host, and return the result of invocing the method on the remote object.
 * @param hostEntry The host to connect to.
 * @throws IOFailure if remote host cannot be connected to.
 */
private synchronized void createProxyMBeansForHost(HostEntry hostEntry){
  Set<ObjectName> remoteObjectNames;
  JMXProxyConnection connection=connectionFactory.getConnection(hostEntry.getName(),hostEntry.getJmxPort(),hostEntry.getRmiPort(),JMX_MONITOR_ROLE_USERNAME,jmxPassword);
  remoteObjectNames=(Set<ObjectName>)connection.query(mBeanQuery);
  for (  ObjectName name : remoteObjectNames) {
    try {
      ProxyMBeanInvocationHandler handler=new ProxyMBeanInvocationHandler(name,hostEntry);
      Class<T> proxyClass=(Class<T>)Proxy.getProxyClass(asInterface.getClassLoader(),new Class[]{asInterface});
      T mbean=proxyClass.getConstructor(InvocationHandler.class).newInstance(handler);
      SingleMBeanObject<T> singleMBeanObject=new SingleMBeanObject<T>(name,mbean,asInterface,mBeanServer);
      singleMBeanObject.register();
    }
 catch (    Exception e) {
      log.warn("String_Node_Str",e);
    }
  }
}

Fixed version (ground truth):
/** 
 * Connects to the given host, and lists all mbeans matching the query. For each of these mbeans, registers a proxymbean, that on any invocation will connect to the remote host, and return the result of invoking the method on the remote object.
 * @param hostEntry The host to connect to.
 * @throws IOFailure if remote host cannot be connected to.
 */
private synchronized void createProxyMBeansForHost(HostEntry hostEntry){
  Set<ObjectName> remoteObjectNames;
  JMXProxyConnection connection=connectionFactory.getConnection(hostEntry.getName(),hostEntry.getJmxPort(),hostEntry.getRmiPort(),JMX_MONITOR_ROLE_USERNAME,jmxPassword);
  remoteObjectNames=(Set<ObjectName>)connection.query(mBeanQuery);
  for (  ObjectName name : remoteObjectNames) {
    try {
      ProxyMBeanInvocationHandler handler=new ProxyMBeanInvocationHandler(name,hostEntry);
      Class<T> proxyClass=(Class<T>)Proxy.getProxyClass(asInterface.getClassLoader(),new Class[]{asInterface});
      T mbean=proxyClass.getConstructor(InvocationHandler.class).newInstance(handler);
      SingleMBeanObject<T> singleMBeanObject=new SingleMBeanObject<T>(name,mbean,asInterface,mBeanServer);
      singleMBeanObject.register();
    }
 catch (    Exception e) {
      log.warn("String_Node_Str",e);
    }
  }
}
Program: 90120
Project: 90120
Buggy source:
/** 
 * Initialises a connection to a remote bean. Then invokes the method on that bean.
 * @param proxy This proxying object. Ignored.
 * @param method The method invoked. This is called on the remote mbean.
 * @param args The arguments to the method. These are given to theremote mbean.
 * @return Whatever the remote mbean returns.
 * @throws IOFailure On trouble establishing the connection.
 * @throws javax.management.RuntimeMBeanException On exceptions in thembean invokations
 * @throws Throwable What ever the remote mbean has thrown.
 */
public Object invoke(Object proxy,Method method,Object[] args) throws Throwable {
  JMXProxyConnection connection;
  try {
    connection=connectionFactory.getConnection(hostEntry.getName(),hostEntry.getJmxPort(),hostEntry.getRmiPort(),JMX_MONITOR_ROLE_USERNAME,jmxPassword);
  }
 catch (  Exception e) {
    throw new IOFailure("String_Node_Str" + hostEntry.getName() + "String_Node_Str"+ hostEntry.getJmxPort()+ "String_Node_Str"+ hostEntry.getTime()+ "String_Node_Str",e);
  }
  T mBean=connection.createProxy(name,asInterface);
  return method.invoke(mBean,args);
}

Fixed version (ground truth):
/** 
 * Initialises a connection to a remote bean. Then invokes the method on that bean.
 * @param proxy This proxying object. Ignored.
 * @param method The method invoked. This is called on the remote mbean.
 * @param args The arguments to the method. These are given to theremote mbean.
 * @return Whatever the remote mbean returns.
 * @throws IOFailure On trouble establishing the connection.
 * @throws javax.management.RuntimeMBeanException On exceptions in thembean invocations
 * @throws Throwable What ever the remote mbean has thrown.
 */
public Object invoke(Object proxy,Method method,Object[] args) throws Throwable {
  JMXProxyConnection connection;
  try {
    connection=connectionFactory.getConnection(hostEntry.getName(),hostEntry.getJmxPort(),hostEntry.getRmiPort(),JMX_MONITOR_ROLE_USERNAME,jmxPassword);
  }
 catch (  Exception e) {
    throw new IOFailure("String_Node_Str" + hostEntry.getName() + "String_Node_Str"+ hostEntry.getJmxPort()+ "String_Node_Str"+ hostEntry.getTime()+ "String_Node_Str",e);
  }
  T mBean=connection.createProxy(name,asInterface);
  return method.invoke(mBean,args);
}
Program: 90121
Project: 90121
Buggy source:
/** 
 * Writes the name of the arcfile to the OutputStream.
 * @param file an arcfile
 * @param os the OutputStream to which data is to be written
 * @return false If listing of this arcfile fails; otherwise true
 */
public boolean processFile(File file,OutputStream os){
  String result=file.getName() + "String_Node_Str";
  ArgumentNotValid.checkNotNull(file,"String_Node_Str");
  try {
    os.write(result.getBytes());
  }
 catch (  IOException e) {
    log.warn("String_Node_Str" + file.getName() + "String_Node_Str",e);
    return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Writes the name of the arcfile to the OutputStream.
 * @param file an arcfile
 * @param os the OutputStream to which data is to be written
 * @return false If listing of this arcfile fails; otherwise true
 */
public boolean processFile(File file,OutputStream os){
  ArgumentNotValid.checkNotNull(file,"String_Node_Str");
  String result=file.getName() + "String_Node_Str";
  try {
    os.write(result.getBytes());
  }
 catch (  IOException e) {
    log.warn("String_Node_Str" + file.getName() + "String_Node_Str",e);
    return false;
  }
  return true;
}
Program: 90123
Project: 90123
Buggy source:
/** 
 * Adds error messages from an exception to the status message errors.
 * @param csm The message we're setting messages on.
 * @param crawlException The exception that got thrown from further in,possibly as far in as Heritrix.
 * @param errorMessage Description of errors that happened during upload.
 * @param missingHostsReport If true, no hosts report was found.
 * @param failedFiles List of files that failed to upload.
 */
private void setErrorMessages(CrawlStatusMessage csm,Throwable crawlException,String errorMessage,boolean missingHostsReport,int failedFiles){
  String fullError="String_Node_Str";
  if (crawlException != null) {
    fullError=crawlException + "String_Node_Str";
    csm.setHarvestErrors(crawlException.toString());
    csm.setHarvestErrorDetails(ExceptionUtils.getStackTrace(crawlException));
  }
  if (errorMessage.length() > 0) {
    String shortDesc="String_Node_Str";
    if (missingHostsReport) {
      shortDesc="String_Node_Str";
    }
    if (failedFiles > 0) {
      if (shortDesc.length() > 0) {
        shortDesc+="String_Node_Str";
      }
      shortDesc+=failedFiles + "String_Node_Str";
    }
    csm.setUploadErrors(shortDesc);
    csm.setUploadErrorDetails(errorMessage);
  }
  fullError+=errorMessage;
  csm.setNotOk(fullError);
}

Fixed version (ground truth):
/** 
 * Adds error messages from an exception to the status message errors.
 * @param csm The message we're setting messages on.
 * @param crawlException The exception that got thrown from further in,possibly as far in as Heritrix.
 * @param errorMessage Description of errors that happened during upload.
 * @param missingHostsReport If true, no hosts report was found.
 * @param failedFiles List of files that failed to upload.
 */
private void setErrorMessages(CrawlStatusMessage csm,Throwable crawlException,String errorMessage,boolean missingHostsReport,int failedFiles){
  if (crawlException != null) {
    csm.setHarvestErrors(crawlException.toString());
    csm.setHarvestErrorDetails(ExceptionUtils.getStackTrace(crawlException));
  }
  if (errorMessage.length() > 0) {
    String shortDesc="String_Node_Str";
    if (missingHostsReport) {
      shortDesc="String_Node_Str";
    }
    if (failedFiles > 0) {
      if (shortDesc.length() > 0) {
        shortDesc+="String_Node_Str";
      }
      shortDesc+=failedFiles + "String_Node_Str";
    }
    csm.setUploadErrors(shortDesc);
    csm.setUploadErrorDetails(errorMessage);
  }
}
Program: 90124
Project: 90124
Buggy source:
/** 
 * Returns or creates the unique instance of this singleton The server creates an instance of the HarvestController, uploads arc-files from unfinshed harvests, and starts to listen to JMS messages on the incoming jms queues.
 * @return The instance
 * @throws PermissionDenied If the serverdir or oldjobsdir can't be created
 * @throws IOFailure if data from old harvests exist, but contain illegal data
 */
public static synchronized HarvestControllerServer getInstance() throws IOFailure {
  if (instance == null) {
    instance=new HarvestControllerServer();
  }
  return instance;
}

Fixed version (ground truth):
/** 
 * Returns or creates the unique instance of this singleton The server creates an instance of the HarvestController, uploads arc-files from unfinished harvests, and starts to listen to JMS messages on the incoming jms queues.
 * @return The instance
 * @throws PermissionDenied If the serverdir or oldjobsdir can't be created
 * @throws IOFailure if data from old harvests exist, but contain illegal data
 */
public static synchronized HarvestControllerServer getInstance() throws IOFailure {
  if (instance == null) {
    instance=new HarvestControllerServer();
  }
  return instance;
}
Program: 90125
Project: 90125
Buggy source:
/** 
 * Cleanup method. Resets HarvestSchedulerMonitorServer singleton. Note: this cleanup() methodm is called from HarvestScheduler.cleanup(), therefore it needs to be public
 */
public void cleanup(){
  instance=null;
}

Fixed version (ground truth):
/** 
 * Cleanup method. Resets HarvestSchedulerMonitorServer singleton. Note: this cleanup() method is called from HarvestScheduler.cleanup(), therefore it needs to be public
 */
public void cleanup(){
  instance=null;
}
Program: 90127
Project: 90127
Buggy source:
/** 
 * Tests processing of leftover jobs in the case where some uploads fail.
 */
public void testProcessHarvestInfoFileFails(){
  CrawlStatusMessage crawlStatusMessage=testProcessingOfLeftoverJobs(TestInfo.LEFTOVER_CRAWLDIR_2,TestInfo.FILES_IN_LEFTOVER_JOB_DIR_2.length + 1,TestInfo.FILES_IN_LEFTOVER_JOB_DIR_2[1]);
  assertNotNull("String_Node_Str",crawlStatusMessage.getErrMsg());
  assertEquals("String_Node_Str","String_Node_Str",crawlStatusMessage.getUploadErrors());
  StringAsserts.assertStringMatches("String_Node_Str","String_Node_Str" + TestInfo.LEFTOVER_JOB_DIR_2_SOME_FILE_PATTERN,crawlStatusMessage.getUploadErrorDetails());
  StringAsserts.assertStringContains("String_Node_Str","String_Node_Str",crawlStatusMessage.getHarvestErrors());
  StringAsserts.assertStringMatches("String_Node_Str","String_Node_Str",crawlStatusMessage.getHarvestErrorDetails());
  assertFalse(crawlStatusMessage.isOk());
  String oldjobsdir=Settings.get(HarvesterSettings.HARVEST_CONTROLLER_OLDJOBSDIR);
  FileUtils.removeRecursively(new File(oldjobsdir));
  crawlStatusMessage=testProcessingOfLeftoverJobs(TestInfo.LEFTOVER_CRAWLDIR_3,0,null);
  assertFalse(crawlStatusMessage.isOk());
  assertNotNull("String_Node_Str",crawlStatusMessage.getErrMsg());
  assertTrue("String_Node_Str",new File(new File(oldjobsdir,TestInfo.LEFTOVER_CRAWLDIR_3.getName()),"String_Node_Str").exists());
  assertTrue("String_Node_Str",new File(new File(oldjobsdir,TestInfo.LEFTOVER_CRAWLDIR_3.getName()),"String_Node_Str").exists());
}

Fixed version (ground truth):
/** 
 * Tests processing of leftover jobs in the case where some uploads fail.
 */
public void testProcessHarvestInfoFileFails(){
  CrawlStatusMessage crawlStatusMessage=testProcessingOfLeftoverJobs(TestInfo.LEFTOVER_CRAWLDIR_2,TestInfo.FILES_IN_LEFTOVER_JOB_DIR_2.length + 1,TestInfo.FILES_IN_LEFTOVER_JOB_DIR_2[1]);
  assertEquals("String_Node_Str","String_Node_Str",crawlStatusMessage.getUploadErrors());
  StringAsserts.assertStringMatches("String_Node_Str","String_Node_Str" + TestInfo.LEFTOVER_JOB_DIR_2_SOME_FILE_PATTERN,crawlStatusMessage.getUploadErrorDetails());
  StringAsserts.assertStringContains("String_Node_Str","String_Node_Str",crawlStatusMessage.getHarvestErrors());
  StringAsserts.assertStringMatches("String_Node_Str","String_Node_Str",crawlStatusMessage.getHarvestErrorDetails());
  assertTrue("String_Node_Str",crawlStatusMessage.isOk());
  String oldjobsdir=Settings.get(HarvesterSettings.HARVEST_CONTROLLER_OLDJOBSDIR);
  FileUtils.removeRecursively(new File(oldjobsdir));
  crawlStatusMessage=testProcessingOfLeftoverJobs(TestInfo.LEFTOVER_CRAWLDIR_3,0,null);
  assertTrue("String_Node_Str",crawlStatusMessage.isOk());
  assertTrue("String_Node_Str",new File(new File(oldjobsdir,TestInfo.LEFTOVER_CRAWLDIR_3.getName()),"String_Node_Str").exists());
  assertTrue("String_Node_Str",new File(new File(oldjobsdir,TestInfo.LEFTOVER_CRAWLDIR_3.getName()),"String_Node_Str").exists());
}
Program: 90128
Project: 90128
Buggy source:
/** 
 * Creates an instance of a BitarchiveMonitorServer.
 * @throws IOFailure - if an error with the JMSConnection occurs
 */
protected BitarchiveMonitorServer() throws IOFailure {
  con.setListener(Channels.getTheBamon(),this);
  bamon=new BitarchiveMonitor();
  bamon.addObserver(this);
  log.info("String_Node_Str" + "String_Node_Str" + Channels.getTheBamon() + "String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Creates an instance of a BitarchiveMonitorServer.
 * @throws IOFailure - if an error with the JMSConnection occurs
 */
protected BitarchiveMonitorServer() throws IOFailure {
  bamon=new BitarchiveMonitor();
  bamon.addObserver(this);
  con.setListener(Channels.getTheBamon(),this);
  log.info("String_Node_Str" + "String_Node_Str" + Channels.getTheBamon() + "String_Node_Str");
}
Program: 90129
Project: 90129
Buggy source:
/** 
 * Unzip a zipFile into a directory.  This will create subdirectories as needed.
 * @param zipFile The file to unzip
 * @param toDir The directory to create the files under.  This directorywill be created if necessary.  Files in it will be overwritten if the filenames match.
 */
public static void unzip(File zipFile,File toDir){
  ArgumentNotValid.checkNotNull(zipFile,"String_Node_Str");
  ArgumentNotValid.checkNotNull(toDir,"String_Node_Str");
  ArgumentNotValid.checkTrue(toDir.getAbsoluteFile().getParentFile().canWrite(),"String_Node_Str" + toDir + "String_Node_Str");
  ArgumentNotValid.checkTrue(zipFile.canRead(),"String_Node_Str" + zipFile + "String_Node_Str");
  try {
    ZipFile unzipper=new ZipFile(zipFile);
    try {
      Enumeration<? extends ZipEntry> entries=unzipper.entries();
      while (entries.hasMoreElements()) {
        ZipEntry ze=entries.nextElement();
        File target=new File(toDir,ze.getName());
        FileUtils.createDir(target.getCanonicalFile().getParentFile());
        InputStream inputStream=unzipper.getInputStream(ze);
        FileUtils.writeStreamToFile(inputStream,target);
        inputStream.close();
      }
    }
  finally {
      unzipper.close();
    }
  }
 catch (  IOException e) {
    throw new IOFailure("String_Node_Str" + zipFile + "String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Unzip a zipFile into a directory.  This will create subdirectories as needed.
 * @param zipFile The file to unzip
 * @param toDir The directory to create the files under.  This directorywill be created if necessary.  Files in it will be overwritten if the filenames match.
 */
public static void unzip(File zipFile,File toDir){
  ArgumentNotValid.checkNotNull(zipFile,"String_Node_Str");
  ArgumentNotValid.checkNotNull(toDir,"String_Node_Str");
  ArgumentNotValid.checkTrue(toDir.getAbsoluteFile().getParentFile().canWrite(),"String_Node_Str" + toDir + "String_Node_Str");
  ArgumentNotValid.checkTrue(zipFile.canRead(),"String_Node_Str" + zipFile + "String_Node_Str");
  InputStream inputStream=null;
  ZipFile unzipper=null;
  try {
    try {
      unzipper=new ZipFile(zipFile);
      Enumeration<? extends ZipEntry> entries=unzipper.entries();
      while (entries.hasMoreElements()) {
        ZipEntry ze=entries.nextElement();
        File target=new File(toDir,ze.getName());
        FileUtils.createDir(target.getCanonicalFile().getParentFile());
        if (ze.isDirectory()) {
          target.mkdir();
        }
 else {
          inputStream=unzipper.getInputStream(ze);
          FileUtils.writeStreamToFile(inputStream,target);
          inputStream.close();
        }
      }
    }
  finally {
      if (unzipper != null) {
        unzipper.close();
      }
      if (inputStream != null) {
        inputStream.close();
      }
    }
  }
 catch (  IOException e) {
    throw new IOFailure("String_Node_Str" + zipFile + "String_Node_Str",e);
  }
}
Program: 90131
Project: 90131
Buggy source:
/** 
 * Check if the crawl has ended, either because Heritrix finished of its own, or because we terminated it.
 * @return True if the crawl has ended, either because Heritrix finishedor because we terminated it. Otherwise we return false.
 */
public synchronized boolean crawlIsEnded(){
  if (processHasExited()) {
    return true;
  }
  TabularData jobs=(TabularData)executeHeritrixCommand(COMPLETED_JOBS_COMMAND);
  if (jobs != null && jobs.size() > 0) {
    for (    CompositeData value : (Collection<CompositeData>)jobs.values()) {
      String thisJobID=value.get(JmxUtils.NAME) + "String_Node_Str" + value.get(UID_PROPERTY);
      if (thisJobID.equals(jobName)) {
        return true;
      }
    }
  }
  String status=(String)getCrawlJobAttribute(STATUS_ATTRIBUTE);
  return status == null || status.startsWith(FINISHED_STATUS_PREFIX) || status.equals(CrawlJob.STATUS_MISCONFIGURED) || status.equals(CrawlJob.STATUS_DELETED);
}

Fixed version (ground truth):
/** 
 * Check if the crawl has ended, either because Heritrix finished of its own, or because we terminated it.
 * @return True if the crawl has ended, either because Heritrix finishedor because we terminated it. Otherwise we return false.
 */
public synchronized boolean crawlIsEnded(){
  if (processHasExited()) {
    return true;
  }
  TabularData jobs=(TabularData)executeHeritrixCommand(COMPLETED_JOBS_COMMAND);
  if (jobs != null && jobs.size() > 0) {
    for (    CompositeData value : (Collection<CompositeData>)jobs.values()) {
      String thisJobID=value.get(JmxUtils.NAME) + "String_Node_Str" + value.get(UID_PROPERTY);
      if (thisJobID.equals(jobName)) {
        return true;
      }
    }
  }
  String status=(String)getCrawlJobAttribute(STATUS_ATTRIBUTE);
  return status == null || status.equals(FINISHED_STATUS) || status.equals(ILLEGAL_STATUS);
}
Program: 90132
Project: 90132
Buggy source:
/** 
 * @see HeritrixController#isPaused()  
 */
public boolean isPaused(){
  String status=(String)getCrawlJobAttribute(STATUS_ATTRIBUTE);
  return status.equals(CrawlJob.STATUS_PAUSED) || status.equals(CrawlJob.STATUS_WAITING_FOR_PAUSE);
}

Fixed version (ground truth):
/** 
 * @see HeritrixController#isPaused()  
 */
public boolean isPaused(){
  String status=(String)getCrawlJobAttribute(STATUS_ATTRIBUTE);
  log.debug("String_Node_Str" + status + "String_Node_Str");
  return status.equals(PAUSED_STATUS) || status.equals(PAUSING_STATUS);
}
Program: 90133
Project: 90133
Buggy source:
/** 
 * Forgiving index generating method, that returns a file with an index of the greatest possible subset of a given id. If the type I for instance is a Set, you may get an index of only a subset. If I is a File, null may be seen as a subset.
 * @see #cache for more information.Please note that you will not know what the actual subset is.
 * @param id The requested index.
 * @return An index over the greatest possible subset.
 */
public File getIndex(I id){
  I response=id;
  I lastResponse=null;
  while (response != null && !response.equals(lastResponse)) {
    if (lastResponse != null) {
      log.info("String_Node_Str" + this.getCacheDir().getName() + "String_Node_Str"+ lastResponse+ "String_Node_Str"+ response+ "String_Node_Str");
    }
    lastResponse=response;
    response=cache(lastResponse);
  }
  File cacheFile=getCacheFile(response);
  log.info("String_Node_Str" + cacheFile + "String_Node_Str"+ response+ "String_Node_Str"+ id+ "String_Node_Str");
  return cacheFile;
}

Fixed version (ground truth):
/** 
 * Forgiving index generating method, that returns a file with an index of the greatest possible subset of a given id. If the type I for instance is a Set, you may get an index of only a subset. If I is a File, null may be seen as a subset.
 * @see #cache for more information.Please note that you will not know what the actual subset is.
 * @param id The requested index.
 * @return An index over the greatest possible subset.
 */
public JobIndexCache.JobIndex<I> getIndex(I id){
  I response=id;
  I lastResponse=null;
  while (response != null && !response.equals(lastResponse)) {
    if (lastResponse != null) {
      log.info("String_Node_Str" + this.getCacheDir().getName() + "String_Node_Str"+ lastResponse+ "String_Node_Str"+ response+ "String_Node_Str");
    }
    lastResponse=response;
    response=cache(lastResponse);
  }
  File cacheFile=getCacheFile(response);
  log.info("String_Node_Str" + cacheFile + "String_Node_Str"+ response+ "String_Node_Str"+ id+ "String_Node_Str");
  return new JobIndexCache.JobIndex(cacheFile,response);
}