nus-yam/ex-repair huggingface dataset:
Program: 4436
Project: 4436
Buggy source:
/** 
 * This method returns the ranges of a file that do no match the expected TigerTree hashes
 * @param is an <tt>InputStream</tt>
 * @return List of <tt>Interval</tt>
 * @throws IOException if there was a problem reading the file
 */
public List getCorruptRanges(InputStream is) throws IOException {
  LOG.trace("String_Node_Str");
  List ret=new ArrayList();
  int n=log2Ceil((int)FILE_SIZE) - DEPTH;
  int nodeSize=1 << n;
  List fileHashes=createTTNodes(nodeSize,FILE_SIZE,is);
  for (int i=0; i < fileHashes.size(); i++) {
    byte[] aHash=(byte[])fileHashes.get(i);
    byte[] bHash=(byte[])NODES.get(i);
    for (int j=0; j < aHash.length; j++) {
      if (aHash[j] != bHash[j]) {
        Interval in=new Interval(i * nodeSize,(int)Math.min((i + 1) * nodeSize - 1,FILE_SIZE - 1));
        ret.add(in);
        if (LOG.isDebugEnabled())         LOG.debug(Base32.encode(ROOT_HASH) + "String_Node_Str" + in);
        break;
      }
    }
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * This method returns the ranges of a file that do no match the expected TigerTree hashes
 * @param is an <tt>InputStream</tt>
 * @return List of <tt>Interval</tt>
 * @throws IOException if there was a problem reading the file
 */
public List getCorruptRanges(InputStream is) throws IOException {
  LOG.trace("String_Node_Str");
  List ret=new ArrayList();
  int n=log2Ceil((int)FILE_SIZE) - DEPTH;
  int nodeSize=1 << n;
  List fileHashes=createTTNodes(nodeSize,FILE_SIZE,is);
  int minSize=Math.min(fileHashes.size(),NODES.size());
  for (int i=0; i < minSize; i++) {
    byte[] aHash=(byte[])fileHashes.get(i);
    byte[] bHash=(byte[])NODES.get(i);
    for (int j=0; j < aHash.length; j++) {
      if (aHash[j] != bHash[j]) {
        Interval in=new Interval(i * nodeSize,(int)Math.min((i + 1) * nodeSize - 1,FILE_SIZE - 1));
        ret.add(in);
        if (LOG.isDebugEnabled())         LOG.debug(Base32.encode(ROOT_HASH) + "String_Node_Str" + in);
        break;
      }
    }
  }
  return ret;
}
Program: 4437
Project: 4437
Buggy source:
public int read(byte[] b,int off,int len) throws IOException {
  int read=super.read(b,off,len);
  _count+=read;
  return read;
}

Fixed version (ground truth):
public int read(byte[] b,int off,int len) throws IOException {
  int read;
  try {
    read=super.read(b,off,len);
  }
 catch (  ArrayIndexOutOfBoundsException aioob) {
    throw new IOException();
  }
  _count+=read;
  return read;
}
Program: 4438
Project: 4438
Buggy source:
private void deserializeFromFile() throws IOException {
  FileInputStream istream=null;
  ObjectInputStream objStream=null;
  try {
    istream=new FileInputStream(_backingStoreFile);
    objStream=new ObjectInputStream(istream);
    _hashMap=(Map)objStream.readObject();
    if (LOG.isDebugEnabled()) {
      for (Iterator it=_hashMap.entrySet().iterator(); it.hasNext(); ) {
        Map.Entry ent=(Map.Entry)it.next();
        LOG.debug("String_Node_Str" + ent.getKey() + "String_Node_Str"+ ent.getValue());
      }
    }
  }
 catch (  ClassNotFoundException cnfe) {
    throw new IOException("String_Node_Str");
  }
catch (  ClassCastException cce) {
    throw new IOException("String_Node_Str");
  }
 finally {
    if (istream != null) {
      try {
        istream.close();
      }
 catch (      IOException ignored) {
      }
    }
  }
}

Fixed version (ground truth):
private void deserializeFromFile() throws IOException {
  FileInputStream istream=null;
  ObjectInputStream objStream=null;
  try {
    istream=new FileInputStream(_backingStoreFile);
    objStream=new ObjectInputStream(istream);
    _hashMap=(Map)objStream.readObject();
    if (LOG.isDebugEnabled()) {
      for (Iterator it=_hashMap.entrySet().iterator(); it.hasNext(); ) {
        Map.Entry ent=(Map.Entry)it.next();
        LOG.debug("String_Node_Str" + ent.getKey() + "String_Node_Str"+ ent.getValue());
      }
    }
  }
 catch (  ClassCastException e) {
    throw new IOException();
  }
catch (  ClassNotFoundException e) {
    throw new IOException();
  }
catch (  ArrayStoreException e) {
    throw new IOException();
  }
catch (  IndexOutOfBoundsException e) {
    throw new IOException();
  }
catch (  NegativeArraySizeException e) {
    throw new IOException();
  }
catch (  IllegalStateException e) {
    throw new IOException();
  }
catch (  SecurityException e) {
    throw new IOException();
  }
 finally {
    if (istream != null) {
      try {
        istream.close();
      }
 catch (      IOException ignored) {
      }
    }
  }
}
Program: 4439
Project: 4439
Buggy source:
/** 
 * Removes and returns the RemoteFileDesc with the highest quality in filesLeft.  If two or more entries have the same quality, returns the entry with the highest speed.  
 * @param filesLeft the list of file/locations to choose from, which MUSThave length of at least one.  Each entry MUST be an instance of RemoteFileDesc.  The assumption is that all are "same", though this isn't strictly needed.
 * @return the best file/endpoint location 
 */
private synchronized RemoteFileDesc removeBest(){
  Iterator iter=files.iterator();
  RemoteFileDesc ret=(RemoteFileDesc)iter.next();
  while (iter.hasNext()) {
    RemoteFileDesc rfd=(RemoteFileDesc)iter.next();
    if (ret.isBusy())     ret=rfd;
 else     if (rfd.getSHA1Urn() != null && ret.getSHA1Urn() == null)     ret=rfd;
 else     if ((rfd.getSHA1Urn() == null) == (ret.getSHA1Urn() == null)) {
      if (rfd.getQuality() > ret.getQuality())       ret=rfd;
 else       if (rfd.getQuality() == ret.getQuality()) {
        if (rfd.getSpeed() > ret.getSpeed())         ret=rfd;
      }
    }
  }
  files.remove(ret);
  return ret;
}

Fixed version (ground truth):
/** 
 * Removes and returns the RemoteFileDesc with the highest quality in filesLeft.  If two or more entries have the same quality, returns the entry with the highest speed.  
 * @param filesLeft the list of file/locations to choose from, which MUSThave length of at least one.  Each entry MUST be an instance of RemoteFileDesc.  The assumption is that all are "same", though this isn't strictly needed.
 * @return the best file/endpoint location 
 */
private synchronized RemoteFileDesc removeBest(){
  Iterator iter=files.iterator();
  RemoteFileDesc ret=(RemoteFileDesc)iter.next();
  while (iter.hasNext()) {
    RemoteFileDesc rfd=(RemoteFileDesc)iter.next();
    if (rfd.isBusy())     continue;
    if (ret.isBusy())     ret=rfd;
 else     if (rfd.getSHA1Urn() != null && ret.getSHA1Urn() == null)     ret=rfd;
 else     if ((rfd.getSHA1Urn() == null) == (ret.getSHA1Urn() == null)) {
      if (rfd.getQuality() > ret.getQuality())       ret=rfd;
 else       if (rfd.getQuality() == ret.getQuality()) {
        if (rfd.getSpeed() > ret.getSpeed())         ret=rfd;
      }
    }
  }
  files.remove(ret);
  return ret;
}
Program: 4441
Project: 4441
Buggy source:
/** 
 * Parses X-Available-Ranges header and stores the available ranges as a list.
 * @param line the X-Available-Ranges header line which should look like:"X-Available-Ranges: bytes A-B, C-D, E-F" "X-Available-Ranges:bytes A-B"
 * @param rfd the RemoteFileDesc2 for the location we are trying to downloadfrom. We need this to store the available Ranges. 
 * @exception ProblemReadingHeaderException when we could not parse the header line.
 */
private void parseAvailableRangesHeader(String line,RemoteFileDesc rfd) throws IOException {
  IntervalSet availableRanges=new IntervalSet();
  line=line.toLowerCase();
  int start=line.indexOf("String_Node_Str") + 6;
  while (start != -1 && start < line.length()) {
    int stop=line.indexOf('-',start);
    if (stop == -1)     break;
    Interval interval=null;
    try {
      int low=Integer.parseInt(line.substring(start,stop).trim());
      start=stop + 1;
      stop=line.indexOf(',',start);
      if (stop == -1)       stop=line.length();
      int high=Integer.parseInt(line.substring(start,stop).trim());
      if (high >= rfd.getSize())       high=rfd.getSize() - 1;
      if (low > high)       continue;
      interval=new Interval(low,high);
      start=stop + 1;
    }
 catch (    NumberFormatException e) {
      throw new ProblemReadingHeaderException(e);
    }
    availableRanges.add(interval);
  }
  Iterator iter=availableRanges.getAllIntervals();
  while (iter.hasNext()) {
    Interval next=(Interval)iter.next();
    if (_requestedInterval.isSubrange(next))     throw new ProblemReadingHeaderException("String_Node_Str");
  }
  rfd.setAvailableRanges(availableRanges);
}

Fixed version (ground truth):
/** 
 * Parses X-Available-Ranges header and stores the available ranges as a list.
 * @param line the X-Available-Ranges header line which should look like:"X-Available-Ranges: bytes A-B, C-D, E-F" "X-Available-Ranges:bytes A-B"
 * @param rfd the RemoteFileDesc2 for the location we are trying to downloadfrom. We need this to store the available Ranges. 
 * @exception ProblemReadingHeaderException when we could not parse the header line.
 */
private void parseAvailableRangesHeader(String line,RemoteFileDesc rfd) throws IOException {
  IntervalSet availableRanges=new IntervalSet();
  line=line.toLowerCase();
  int start=line.indexOf("String_Node_Str") + 6;
  while (start != -1 && start < line.length()) {
    int stop=line.indexOf('-',start);
    if (stop == -1)     break;
    Interval interval=null;
    try {
      int low=Integer.parseInt(line.substring(start,stop).trim());
      start=stop + 1;
      stop=line.indexOf(',',start);
      if (stop == -1)       stop=line.length();
      int high=Integer.parseInt(line.substring(start,stop).trim());
      if (high >= rfd.getSize())       high=rfd.getSize() - 1;
      if (low > high)       continue;
      interval=new Interval(low,high);
      start=stop + 1;
    }
 catch (    NumberFormatException e) {
      throw new ProblemReadingHeaderException(e);
    }
    availableRanges.add(interval);
  }
  rfd.setAvailableRanges(availableRanges);
}
Program: 4444
Project: 4444
Buggy source:
/** 
 * @return a <tt>Set</tt> of <tt>PushProxyContainer</tt> instances,which can be empty but is guaranteed not to be <tt>null</tt>, as  described by the GGEP blocks.
 * @param ggeps the array of GGEP extensions that may or may notcontain push proxy data
 */
public Set getPushProxies(GGEP[] ggeps){
  Set proxies=new HashSet();
  for (int i=0; (ggeps != null) && (i < ggeps.length); i++) {
    Set headers=ggeps[i].getHeaders();
    if (headers.contains(GGEP.GGEP_HEADER_PUSH_PROXY)) {
      byte[] proxyBytes=null;
      try {
        proxyBytes=ggeps[i].getBytes(GGEP.GGEP_HEADER_PUSH_PROXY);
      }
 catch (      BadGGEPPropertyException bad) {
        ErrorService.error(bad);
        continue;
      }
      ByteArrayInputStream bais=new ByteArrayInputStream(proxyBytes);
      while (bais.available() > 0) {
        byte[] combo=new byte[6];
        if (bais.read(combo,0,combo.length) == combo.length) {
          try {
            proxies.add(new PushProxyContainer(combo));
          }
 catch (          BadPacketException malformedPair) {
          }
        }
      }
    }
  }
  return proxies;
}

Fixed version (ground truth):
/** 
 * @return a <tt>Set</tt> of <tt>PushProxyContainer</tt> instances,which can be empty but is guaranteed not to be <tt>null</tt>, as  described by the GGEP blocks.
 * @param ggeps the array of GGEP extensions that may or may notcontain push proxy data
 */
public Set getPushProxies(GGEP[] ggeps){
  Set proxies=new HashSet();
  for (int i=0; (ggeps != null) && (i < ggeps.length); i++) {
    Set headers=ggeps[i].getHeaders();
    if (headers.contains(GGEP.GGEP_HEADER_PUSH_PROXY)) {
      byte[] proxyBytes=null;
      try {
        proxyBytes=ggeps[i].getBytes(GGEP.GGEP_HEADER_PUSH_PROXY);
      }
 catch (      BadGGEPPropertyException bad) {
        continue;
      }
      ByteArrayInputStream bais=new ByteArrayInputStream(proxyBytes);
      while (bais.available() > 0) {
        byte[] combo=new byte[6];
        if (bais.read(combo,0,combo.length) == combo.length) {
          try {
            proxies.add(new PushProxyContainer(combo));
          }
 catch (          BadPacketException malformedPair) {
          }
        }
      }
    }
  }
  return proxies;
}
Program: 4451
Project: 4451
Buggy source:
/** 
 * Notification that a file has changed. This implementation is different than FileManager's in that it maintains the XML. Important note: This method is called AFTER the file has changed.  It is possible that the metadata we wanted to write did not get written out completely.  We should NOT attempt to add the old metadata again, because we may end up recursing infinitely trying to write this metadata. However, it isn't very robust to blindly assume that the only metadata associated with this file was audio metadata. So, we make use of the fact that addFileIfShared will only add one type of metadata per file.  We read the ID3 tags off the file and insert it first into the list, ensuring that the existing metadata is the one that's added, short-circuiting any infinite loops.
 */
public FileDesc fileChanged(File f){
  FileDesc fd=getFileDescForFile(f);
  if (fd == null)   return null;
  CreationTimeCache ctCache=CreationTimeCache.instance();
  Long cTime=ctCache.getCreationTime(fd.getSHA1Urn());
  List xmlDocs=new LinkedList();
  if (LimeXMLUtils.isMP3File(f)) {
    try {
      xmlDocs.add(ID3Reader.readDocument(f));
    }
 catch (    IOException e) {
      return super.fileChanged(f);
    }
  }
  xmlDocs.addAll(fd.getLimeXMLDocuments());
  FileDesc removed=removeFileIfShared(f);
  Assert.that(fd == removed,"String_Node_Str");
  _needRebuild=true;
  fd=addFileIfShared(f,xmlDocs);
  if ((fd != null) && (cTime != null)) {
synchronized (ctCache) {
      ctCache.removeTime(fd.getSHA1Urn());
      ctCache.addTime(fd.getSHA1Urn(),cTime.longValue());
      ctCache.commitTime(fd.getSHA1Urn());
    }
  }
  return fd;
}

Fixed version (ground truth):
/** 
 * Notification that a file has changed. This implementation is different than FileManager's in that it maintains the XML. Important note: This method is called AFTER the file has changed.  It is possible that the metadata we wanted to write did not get written out completely.  We should NOT attempt to add the old metadata again, because we may end up recursing infinitely trying to write this metadata. However, it isn't very robust to blindly assume that the only metadata associated with this file was audio metadata. So, we make use of the fact that addFileIfShared will only add one type of metadata per file.  We read the ID3 tags off the file and insert it first into the list, ensuring that the existing metadata is the one that's added, short-circuiting any infinite loops.
 */
public FileDesc fileChanged(File f){
  FileDesc fd=getFileDescForFile(f);
  if (fd == null)   return null;
  CreationTimeCache ctCache=CreationTimeCache.instance();
  Long cTime=ctCache.getCreationTime(fd.getSHA1Urn());
  List xmlDocs=new LinkedList();
  xmlDocs.addAll(fd.getLimeXMLDocuments());
  FileDesc removed=removeFileIfShared(f);
  Assert.that(fd == removed,"String_Node_Str");
  _needRebuild=true;
  fd=addFileIfShared(f,xmlDocs);
  if ((fd != null) && (cTime != null)) {
synchronized (ctCache) {
      ctCache.removeTime(fd.getSHA1Urn());
      ctCache.addTime(fd.getSHA1Urn(),cTime.longValue());
      ctCache.commitTime(fd.getSHA1Urn());
    }
  }
  return fd;
}
Program: 4453
Project: 4453
Buggy source:
/** 
 * Changes the DatagramSocket used for sending/receiving.  Typically called by Acceptor to commit to the new port.
 * @param datagramSocket the new listening socket, which must be be thereturn value of newListeningSocket(int).  A value of null disables  UDP sending and receiving.
 */
void setListeningSocket(DatagramSocket datagramSocket){
  if (_socket != null)   _socket.close();
synchronized (_receiveLock) {
synchronized (_sendLock) {
      if (_socket == null)       _socketSetOnce=true;
      _socket=(DatagramSocket)datagramSocket;
      _receiveLock.notify();
      _sendLock.notify();
    }
  }
}

Fixed version (ground truth):
/** 
 * Changes the DatagramSocket used for sending/receiving.  Typically called by Acceptor to commit to the new port.
 * @param datagramSocket the new listening socket, which must be be thereturn value of newListeningSocket(int).  A value of null disables  UDP sending and receiving.
 */
void setListeningSocket(DatagramSocket datagramSocket){
  if (_socket != null)   _socket.close();
synchronized (_receiveLock) {
synchronized (_sendLock) {
      if ((_socket == null) && (datagramSocket != null))       _socketSetOnce=true;
      if (_socketSetOnce && (datagramSocket == null))       _socketSetOnce=false;
      _socket=(DatagramSocket)datagramSocket;
      _receiveLock.notify();
      _sendLock.notify();
    }
  }
}
Program: 4455
Project: 4455
Buggy source:
/** 
 * Returns the number of invalid alternate locations that this download is using.
 */
public int getNumberOfInvalidAlternateLocations(){
  if (invalidAlts == null)   return 0;
  return invalidAlts.size();
}

Fixed version (ground truth):
/** 
 * Returns the number of invalid alternate locations that this download is using.
 */
public synchronized int getNumberOfInvalidAlternateLocations(){
  if (invalidAlts == null)   return 0;
  return invalidAlts.size();
}
Program: 4456
Project: 4456
Buggy source:
private static List createTTNodes(int nodeSize,long fileSize,InputStream is) throws IOException {
  List ret=new ArrayList((int)Math.ceil((double)fileSize / nodeSize));
  MessageDigest tt=new TigerTree();
  byte[] block=new byte[BLOCK_SIZE * 128];
  long offset=0;
  int read=0;
  while (offset < fileSize) {
    int nodeOffset=0;
    long time=System.currentTimeMillis();
    tt.reset();
    while (nodeOffset < nodeSize && (read=is.read(block)) != -1) {
      tt.update(block,0,read);
      nodeOffset+=read;
      offset+=read;
      try {
        Thread.sleep((System.currentTimeMillis() - time) * 2);
      }
 catch (      InterruptedException ie) {
        throw new IOException("String_Node_Str");
      }
      time=System.currentTimeMillis();
    }
    ret.add(tt.digest());
    if (offset == fileSize) {
      if (read != -1 && is.read() != -1) {
        LOG.warn("String_Node_Str");
        throw new IOException("String_Node_Str");
      }
    }
 else     if (read == -1 && offset != fileSize) {
      if (LOG.isWarnEnabled()) {
        LOG.warn("String_Node_Str" + "String_Node_Str" + read + "String_Node_Str"+ offset+ "String_Node_Str"+ fileSize);
      }
      throw new IOException("String_Node_Str");
    }
  }
  return ret;
}

Fixed version (ground truth):
private static List createTTNodes(int nodeSize,long fileSize,InputStream is) throws IOException {
  List ret=new ArrayList((int)Math.ceil((double)fileSize / nodeSize));
  MessageDigest tt=new TigerTree();
  byte[] block=new byte[BLOCK_SIZE * 128];
  long offset=0;
  int read=0;
  while (offset < fileSize) {
    int nodeOffset=0;
    long time=System.currentTimeMillis();
    tt.reset();
    while (nodeOffset < nodeSize && (read=is.read(block)) != -1) {
      tt.update(block,0,read);
      nodeOffset+=read;
      offset+=read;
      try {
        long sleep=(System.currentTimeMillis() - time) * 2;
        if (sleep > 0)         Thread.sleep(sleep);
      }
 catch (      InterruptedException ie) {
        throw new IOException("String_Node_Str");
      }
      time=System.currentTimeMillis();
    }
    ret.add(tt.digest());
    if (offset == fileSize) {
      if (read != -1 && is.read() != -1) {
        LOG.warn("String_Node_Str");
        throw new IOException("String_Node_Str");
      }
    }
 else     if (read == -1 && offset != fileSize) {
      if (LOG.isWarnEnabled()) {
        LOG.warn("String_Node_Str" + "String_Node_Str" + read + "String_Node_Str"+ offset+ "String_Node_Str"+ fileSize);
      }
      throw new IOException("String_Node_Str");
    }
  }
  return ret;
}
Program: 4457
Project: 4457
Buggy source:
public void testLegacy() throws Exception {
  AutoDownloadDetails details=new AutoDownloadDetails("String_Node_Str","String_Node_Str",new byte[16],new MediaType("String_Node_Str","String_Node_Str","String_Node_Str",new String[0]));
  IncompleteFileManager ifm=new IncompleteFileManager();
  VerifyingFile vf=new VerifyingFile(true,100);
  vf.addInterval(new Interval(10,20));
  ifm.addEntry(new File("String_Node_Str"),vf);
  RequeryDownloader downloader=new RequeryDownloader(ifm,details,null);
  downloader.initialize(new DownloadManager(),new SimpleFileManager(),new ActivityCallbackStub(),false);
  File tmp=File.createTempFile("String_Node_Str","String_Node_Str");
  ObjectOutputStream out=new ObjectOutputStream(new FileOutputStream(tmp));
  out.writeObject(downloader);
  out.close();
  ObjectInputStream in=new ObjectInputStream(new FileInputStream(tmp));
  RequeryDownloader downloader2=(RequeryDownloader)in.readObject();
  in.close();
  assertEquals(downloader.hasFile(),downloader2.hasFile());
  tmp.delete();
}

Fixed version (ground truth):
public void testLegacy() throws Exception {
  AutoDownloadDetails details=new AutoDownloadDetails("String_Node_Str","String_Node_Str",new byte[16],new MediaType("String_Node_Str","String_Node_Str",new String[0]));
  IncompleteFileManager ifm=new IncompleteFileManager();
  VerifyingFile vf=new VerifyingFile(true,100);
  vf.addInterval(new Interval(10,20));
  ifm.addEntry(new File("String_Node_Str"),vf);
  RequeryDownloader downloader=new RequeryDownloader(ifm,details,null);
  downloader.initialize(new DownloadManager(),new SimpleFileManager(),new ActivityCallbackStub(),false);
  File tmp=File.createTempFile("String_Node_Str","String_Node_Str");
  ObjectOutputStream out=new ObjectOutputStream(new FileOutputStream(tmp));
  out.writeObject(downloader);
  out.close();
  ObjectInputStream in=new ObjectInputStream(new FileInputStream(tmp));
  RequeryDownloader downloader2=(RequeryDownloader)in.readObject();
  in.close();
  assertEquals(downloader.hasFile(),downloader2.hasFile());
  tmp.delete();
}
Program: 4458
Project: 4458
Buggy source:
/** 
 * Writes this mp3 file to disk, using the XML in the doc.
 */
public int mp3ToDisk(String mp3FileName,LimeXMLDocument doc){
  boolean wrote=false;
  int mp3WriteState=-1;
  debug("String_Node_Str" + mp3FileName + "String_Node_Str");
  ID3Editor commitWith=ripMP3XML(mp3FileName,doc);
  if (commitWith != null)   mp3WriteState=commitID3Data(mp3FileName,commitWith);
  Assert.that(mp3WriteState != INCORRECT_FILETYPE,"String_Node_Str");
  wrote=write();
  if (!wrote)   return RW_ERROR;
  return mp3WriteState;
}

Fixed version (ground truth):
/** 
 * Writes this mp3 file to disk, using the XML in the doc.
 */
public int mp3ToDisk(FileDesc fd,String mp3FileName,LimeXMLDocument doc,boolean checkBetter){
  boolean wrote=false;
  int mp3WriteState=-1;
  debug("String_Node_Str" + mp3FileName + "String_Node_Str");
  ID3Editor commitWith=ripMP3XML(mp3FileName,doc,checkBetter);
  if (commitWith != null) {
    if (commitWith.getCorrectDocument() == null)     mp3WriteState=commitID3Data(mp3FileName,commitWith);
 else {
      removeDoc(fd);
      addReply(fd,commitWith.getCorrectDocument());
      mp3WriteState=NORMAL;
    }
  }
  Assert.that(mp3WriteState != INCORRECT_FILETYPE,"String_Node_Str");
  wrote=write();
  if (!wrote)   return RW_ERROR;
  return mp3WriteState;
}
Program: 4459
Project: 4459
Buggy source:
/** 
 * Determines whether or not this LimeXMLDocument can or should be commited to disk to replace the ID3 tags in the mp3File. If the ID3 tags in the file are the same as those in document, this returns null (indicating no changes required).
 * @return An ID3Editor to use when committing or null if nothing should be editted.
 */
private ID3Editor ripMP3XML(String mp3File,LimeXMLDocument doc){
  if (!LimeXMLUtils.isMP3File(mp3File))   return null;
  ID3Editor newValues=new ID3Editor();
  String newXML=null;
  try {
    newXML=doc.getXMLStringWithIdentifier();
  }
 catch (  SchemaNotFoundException snfe) {
    return null;
  }
  newValues.removeID3Tags(newXML);
  ID3Editor existing=new ID3Editor();
  LimeXMLDocument existingDoc=null;
  try {
    existingDoc=ID3Reader.readDocument(new File(mp3File));
  }
 catch (  IOException e) {
    return null;
  }
  String existingXML=null;
  try {
    existingXML=existingDoc.getXMLStringWithIdentifier();
  }
 catch (  SchemaNotFoundException snfe) {
    return null;
  }
  existing.removeID3Tags(existingXML);
  if (newValues.equals(existing)) {
    debug("String_Node_Str");
    return null;
  }
  return newValues;
}

Fixed version (ground truth):
/** 
 * Determines whether or not this LimeXMLDocument can or should be commited to disk to replace the ID3 tags in the mp3File. If the ID3 tags in the file are the same as those in document, this returns null (indicating no changes required).
 * @return An ID3Editor to use when committing or null if nothing should be editted.
 */
private ID3Editor ripMP3XML(String mp3File,LimeXMLDocument doc,boolean checkBetter){
  if (!LimeXMLUtils.isMP3File(mp3File))   return null;
  ID3Editor newValues=new ID3Editor();
  String newXML=null;
  try {
    newXML=doc.getXMLStringWithIdentifier();
  }
 catch (  SchemaNotFoundException snfe) {
    return null;
  }
  newValues.removeID3Tags(newXML);
  ID3Editor existing=new ID3Editor();
  LimeXMLDocument existingDoc=null;
  try {
    existingDoc=ID3Reader.readDocument(new File(mp3File));
  }
 catch (  IOException e) {
    return null;
  }
  String existingXML=null;
  try {
    existingXML=existingDoc.getXMLStringWithIdentifier();
  }
 catch (  SchemaNotFoundException snfe) {
    return null;
  }
  existing.removeID3Tags(existingXML);
  if (!checkBetter) {
    if (newValues.equals(existing))     return null;
 else     return newValues;
  }
  if (newValues.equals(existing)) {
    debug("String_Node_Str");
    return null;
  }
 else   if (existing.betterThan(newValues)) {
    existing.setCorrectDocument(existingDoc);
    return existing;
  }
 else   newValues.pickBetterFields(existing);
  return newValues;
}
Program: 4461
Project: 4461
Buggy source:
/** 
 * Adds a reply into the mainMap of this collection, associating the FileDesc with the LimeXMLDocument. If this collection is an audio collection, this will write out the file to disk, possibly adding/changing ID3 tags on an MP3 file. If the file changed because of this operation, the FileManager is notified of the changed file, redoing its hashes. Regardless of whether or not this collection is for audio files, the map of (URN -> LimeXMLDocument) will always be serialized to disk.
 */
void addReplyWithCommit(File f,FileDesc fd,LimeXMLDocument replyDoc){
  addReply(fd,replyDoc);
  if (audio) {
    try {
      mp3ToDisk(f.getCanonicalPath(),replyDoc);
    }
 catch (    IOException ignored) {
    }
  }
 else   write();
}

Fixed version (ground truth):
/** 
 * Adds a reply into the mainMap of this collection, associating the FileDesc with the LimeXMLDocument. If this collection is an audio collection, this will write out the file to disk, possibly adding/changing ID3 tags on an MP3 file. If the file changed because of this operation, the FileManager is notified of the changed file, redoing its hashes. Regardless of whether or not this collection is for audio files, the map of (URN -> LimeXMLDocument) will always be serialized to disk.
 */
void addReplyWithCommit(File f,FileDesc fd,LimeXMLDocument replyDoc,boolean checkBetter){
  addReply(fd,replyDoc);
  if (audio) {
    try {
      mp3ToDisk(fd,f.getCanonicalPath(),replyDoc,checkBetter);
    }
 catch (    IOException ignored) {
    }
  }
 else   write();
}
Program: 4462
Project: 4462
Buggy source:
/** 
 * @modifies this
 * @effects calls addFileIfShared(file), then stores any metadata from thegiven XML documents.  metadata may be null if there is no data.  Returns the value from addFileIfShared.  Returns the value from addFileIfShared. <b>WARNING: this is a potential security hazard.</b> 
 * @return The FileDesc that was added, or null if nothing added.
 */
public FileDesc addFileIfShared(File file,List metadata){
  FileDesc fd=super.addFileIfShared(file);
  if (fd == null)   return null;
  if (metadata == null || metadata.size() == 0) {
    if (!LimeXMLUtils.isMP3File(file))     return fd;
    LimeXMLDocument doc;
    try {
      doc=ID3Reader.readDocument(file);
    }
 catch (    IOException ioe) {
      return fd;
    }
    metadata=new LinkedList();
    metadata.add(doc);
  }
  SchemaReplyCollectionMapper mapper=SchemaReplyCollectionMapper.instance();
  List schemasAddedTo=new LinkedList();
  for (Iterator iter=metadata.iterator(); iter.hasNext(); ) {
    LimeXMLDocument currDoc=(LimeXMLDocument)iter.next();
    String uri=currDoc.getSchemaURI();
    LimeXMLReplyCollection collection=mapper.getReplyCollection(uri);
    if (collection != null && !schemasAddedTo.contains(uri)) {
      schemasAddedTo.add(uri);
      if (ID3Reader.isCorrupted(currDoc))       currDoc=ID3Reader.fixCorruption(currDoc);
      collection.addReplyWithCommit(file,fd,currDoc);
    }
  }
  _needRebuild=true;
  return fd;
}

Fixed version (ground truth):
/** 
 * @modifies this
 * @effects calls addFileIfShared(file), then stores any metadata from thegiven XML documents.  metadata may be null if there is no data.  Returns the value from addFileIfShared.  Returns the value from addFileIfShared. <b>WARNING: this is a potential security hazard.</b> 
 * @return The FileDesc that was added, or null if nothing added.
 */
public FileDesc addFileIfShared(File file,List metadata){
  FileDesc fd=super.addFileIfShared(file);
  if (fd == null)   return null;
  if (metadata == null || metadata.size() == 0) {
    if (!LimeXMLUtils.isMP3File(file))     return fd;
    LimeXMLDocument doc;
    try {
      doc=ID3Reader.readDocument(file);
    }
 catch (    IOException ioe) {
      return fd;
    }
    metadata=new LinkedList();
    metadata.add(doc);
  }
  SchemaReplyCollectionMapper mapper=SchemaReplyCollectionMapper.instance();
  List schemasAddedTo=new LinkedList();
  for (Iterator iter=metadata.iterator(); iter.hasNext(); ) {
    LimeXMLDocument currDoc=(LimeXMLDocument)iter.next();
    String uri=currDoc.getSchemaURI();
    LimeXMLReplyCollection collection=mapper.getReplyCollection(uri);
    if (collection != null && !schemasAddedTo.contains(uri)) {
      schemasAddedTo.add(uri);
      if (ID3Reader.isCorrupted(currDoc))       currDoc=ID3Reader.fixCorruption(currDoc);
      collection.addReplyWithCommit(file,fd,currDoc,true);
    }
  }
  _needRebuild=true;
  return fd;
}
Program: 4466
Project: 4466
Buggy source:
/** 
 * Creates a new <tt>ConnectionChecker</tt> instance that checks for a live internet connection.  If the checker determines that there is no active  connection, it will notify the <tt>ConnectionManager</tt> to take appropriate action.
 * @return a new <tt>ConnectionChecker</tt> instance
 */
public static ConnectionChecker checkForLiveConnection(){
  LOG.trace("String_Node_Str");
  ConnectionChecker checker=new ConnectionChecker();
  Thread connectionThread=new ManagedThread(checker,"String_Node_Str");
  connectionThread.setDaemon(false);
  connectionThread.setDaemon(true);
  connectionThread.start();
  return checker;
}

Fixed version (ground truth):
/** 
 * Creates a new <tt>ConnectionChecker</tt> instance that checks for a live internet connection.  If the checker determines that there is no active  connection, it will notify the <tt>ConnectionManager</tt> to take appropriate action.
 * @return a new <tt>ConnectionChecker</tt> instance
 */
public static ConnectionChecker checkForLiveConnection(){
  LOG.trace("String_Node_Str");
  ConnectionChecker checker=new ConnectionChecker();
  Thread connectionThread=new ManagedThread(checker,"String_Node_Str");
  connectionThread.setDaemon(true);
  connectionThread.start();
  return checker;
}
Program: 4467
Project: 4467
Buggy source:
/** 
 * @requires this' monitor held
 * @modifies this
 * @effects returns the highest priority endpoint in queue, regardlessof quick-connect settings, etc.  Throws NoSuchElementException if this is empty.
 */
private ExtendedEndpoint getAnEndpointInternal() throws NoSuchElementException {
  if (RouterService.isSupernode() && !FREE_ULTRAPEER_SLOTS_SET.isEmpty()) {
    Iterator iter=FREE_ULTRAPEER_SLOTS_SET.iterator();
    ExtendedEndpoint ee=(ExtendedEndpoint)iter.next();
    iter.remove();
    return ee;
  }
 else   if (RouterService.isShieldedLeaf() && !FREE_LEAF_SLOTS_SET.isEmpty()) {
    Iterator iter=FREE_LEAF_SLOTS_SET.iterator();
    ExtendedEndpoint ee=(ExtendedEndpoint)iter.next();
    iter.remove();
    return ee;
  }
 else   if (!FREE_ULTRAPEER_SLOTS_SET.isEmpty()) {
    Iterator iter=FREE_ULTRAPEER_SLOTS_SET.iterator();
    ExtendedEndpoint ee=(ExtendedEndpoint)iter.next();
    iter.remove();
    return ee;
  }
  if (!ENDPOINT_QUEUE.isEmpty()) {
    ExtendedEndpoint e=(ExtendedEndpoint)ENDPOINT_QUEUE.extractMax();
    boolean ok=ENDPOINT_SET.remove(e);
    Assert.that(ok,"String_Node_Str");
    return e;
  }
 else   throw new NoSuchElementException();
}

Fixed version (ground truth):
/** 
 * @requires this' monitor held
 * @modifies this
 * @effects returns the highest priority endpoint in queue, regardlessof quick-connect settings, etc.  Throws NoSuchElementException if this is empty.
 */
private ExtendedEndpoint getAnEndpointInternal() throws NoSuchElementException {
  if (RouterService.isSupernode() && !FREE_ULTRAPEER_SLOTS_SET.isEmpty()) {
    Iterator iter=FREE_ULTRAPEER_SLOTS_SET.iterator();
    ExtendedEndpoint ee=(ExtendedEndpoint)iter.next();
    iter.remove();
    return ee;
  }
 else   if (RouterService.isShieldedLeaf() && !FREE_LEAF_SLOTS_SET.isEmpty()) {
    Iterator iter=FREE_LEAF_SLOTS_SET.iterator();
    ExtendedEndpoint ee=(ExtendedEndpoint)iter.next();
    iter.remove();
    return ee;
  }
 else   if (!FREE_ULTRAPEER_SLOTS_SET.isEmpty()) {
    Iterator iter=FREE_ULTRAPEER_SLOTS_SET.iterator();
    ExtendedEndpoint ee=(ExtendedEndpoint)iter.next();
    iter.remove();
    return ee;
  }
 else   if (!FREE_LEAF_SLOTS_SET.isEmpty()) {
    Iterator iter=FREE_LEAF_SLOTS_SET.iterator();
    ExtendedEndpoint ee=(ExtendedEndpoint)iter.next();
    iter.remove();
    return ee;
  }
  if (!ENDPOINT_QUEUE.isEmpty()) {
    ExtendedEndpoint e=(ExtendedEndpoint)ENDPOINT_QUEUE.extractMax();
    boolean ok=ENDPOINT_SET.remove(e);
    Assert.that(ok,"String_Node_Str");
    return e;
  }
 else   throw new NoSuchElementException();
}
Program: 4469
Project: 4469
Buggy source:
/** 
 * Returns the URN for the bucket with the most entries.
 */
synchronized URN getBestURN(){
  int index=0;
  final int numBuckets=buckets.size();
  for (int i=0, maxNum=0; i < numBuckets; i++) {
    List currBucket=(List)buckets.get(i);
    if (currBucket.size() > maxNum) {
      maxNum=currBucket.size();
      index=i;
    }
  }
  return sha1s[index];
}

Fixed version (ground truth):
/** 
 * Returns the URN for the bucket with the most entries.  May return null.
 */
synchronized URN getBestURN(){
  if (sha1s.length < 1)   return null;
  int index=0;
  final int numBuckets=buckets.size();
  for (int i=0, maxNum=0; i < numBuckets; i++) {
    List currBucket=(List)buckets.get(i);
    if (currBucket.size() > maxNum) {
      maxNum=currBucket.size();
      index=i;
    }
  }
  if (index < sha1s.length)   return sha1s[index];
 else   return null;
}
Program: 4470
Project: 4470
Buggy source:
/** 
 * Writes the common headers -- headers that all LimeWires should send, like Query-Routing and User-Agent.
 */
private static void addCommonHeaders(Properties props){
  props.put(HeaderNames.X_QUERY_ROUTING,QUERY_ROUTING_VERSION);
  props.put(HeaderNames.USER_AGENT,CommonUtils.getHttpServer());
  props.put(HeaderNames.GGEP,"String_Node_Str");
  props.put(HeaderNames.X_GUESS,"String_Node_Str");
  props.put(HeaderNames.X_VENDOR_MESSAGE,"String_Node_Str");
  props.put(HeaderNames.X_DEGREE,Integer.toString(ConnectionManager.ULTRAPEER_CONNECTIONS));
  props.put(HeaderNames.X_ULTRAPEER_QUERY_ROUTING,QUERY_ROUTING_VERSION);
  props.put(HeaderNames.X_MAX_TTL,"String_Node_Str");
  props.put(HeaderNames.X_DYNAMIC_QUERY,"String_Node_Str");
  if (ConnectionSettings.ACCEPT_DEFLATE.getValue())   props.put(HeaderNames.ACCEPT_ENCODING,HeaderNames.DEFLATE_VALUE);
  props.put(HeaderNames.X_PONG_CACHING,"String_Node_Str");
  UpdateManager updateManager=UpdateManager.instance();
  String latestVersion=updateManager.getVersion();
  if (updateManager.isValid() && !latestVersion.equals("String_Node_Str"))   props.put(HeaderNames.X_VERSION,latestVersion);
}

Fixed version (ground truth):
/** 
 * Writes the common headers -- headers that all LimeWires should send, like Query-Routing and User-Agent.
 */
private static void addCommonHeaders(Properties props){
  props.put(HeaderNames.X_QUERY_ROUTING,QUERY_ROUTING_VERSION);
  props.put(HeaderNames.USER_AGENT,CommonUtils.getHttpServer());
  props.put(HeaderNames.GGEP,"String_Node_Str");
  props.put(HeaderNames.X_GUESS,"String_Node_Str");
  props.put(HeaderNames.X_VENDOR_MESSAGE,"String_Node_Str");
  props.put(HeaderNames.X_DEGREE,Integer.toString(ConnectionManager.ULTRAPEER_CONNECTIONS));
  props.put(HeaderNames.X_ULTRAPEER_QUERY_ROUTING,QUERY_ROUTING_VERSION);
  props.put(HeaderNames.X_MAX_TTL,"String_Node_Str");
  props.put(HeaderNames.X_DYNAMIC_QUERY,"String_Node_Str");
  props.put(HeaderNames.X_LOCALE_PREF,ApplicationSettings.LANGUAGE.getValue());
  if (ConnectionSettings.ACCEPT_DEFLATE.getValue())   props.put(HeaderNames.ACCEPT_ENCODING,HeaderNames.DEFLATE_VALUE);
  props.put(HeaderNames.X_PONG_CACHING,"String_Node_Str");
  UpdateManager updateManager=UpdateManager.instance();
  String latestVersion=updateManager.getVersion();
  if (updateManager.isValid() && !latestVersion.equals("String_Node_Str"))   props.put(HeaderNames.X_VERSION,latestVersion);
}
Program: 4471
Project: 4471
Buggy source:
/** 
 * Adds the ultrapeer GGEP extension to the pong.  This has the version of the Ultrapeer protocol that we support as well as the number of free leaf and Ultrapeer slots available.
 * @param ggep the <tt>GGEP</tt> instance to add the extension to
 */
private static void addUltrapeerExtension(GGEP ggep){
  byte[] payload=new byte[3];
  payload[0]=convertToGUESSFormat(CommonUtils.getUPMajorVersionNumber(),CommonUtils.getUPMinorVersionNumber());
  payload[1]=(byte)RouterService.getNumFreeLeafSlots();
  payload[2]=(byte)RouterService.getNumFreeNonLeafSlots();
  ggep.put(GGEP.GGEP_HEADER_UP_SUPPORT,payload);
}

Fixed version (ground truth):
/** 
 * Adds the ultrapeer GGEP extension to the pong.  This has the version of the Ultrapeer protocol that we support as well as the number of free leaf and Ultrapeer slots available.
 * @param ggep the <tt>GGEP</tt> instance to add the extension to
 */
private static void addUltrapeerExtension(GGEP ggep){
  byte[] payload=new byte[3];
  payload[0]=convertToGUESSFormat(CommonUtils.getUPMajorVersionNumber(),CommonUtils.getUPMinorVersionNumber());
  payload[1]=(byte)RouterService.getNumFreeLimeWireLeafSlots();
  payload[2]=(byte)RouterService.getNumFreeLimeWireNonLeafSlots();
  ggep.put(GGEP.GGEP_HEADER_UP_SUPPORT,payload);
}
Program: 4472
Project: 4472
Buggy source:
private void populateValues(Document doc){
  Element docElement=doc.getDocumentElement();
  NodeList children=docElement.getChildNodes();
  int len=children.getLength();
  for (int i=0; i < len; i++) {
    Node node=children.item(i);
    String name=node.getNodeName().toLowerCase().trim();
    if (name.equals("String_Node_Str"))     newVersion=LimeXMLUtils.getText(node.getChildNodes());
 else     if (name.equals("String_Node_Str"))     updateMessage=getLocaleSpecificMessage(node);
  }
}

Fixed version (ground truth):
private void populateValues(Document doc) throws IOException {
  Element docElement=doc.getDocumentElement();
  NodeList children=docElement.getChildNodes();
  int len=children.getLength();
  for (int i=0; i < len; i++) {
    Node node=children.item(i);
    String name=node.getNodeName().toLowerCase().trim();
    if (name.equals("String_Node_Str"))     newVersion=LimeXMLUtils.getText(node.getChildNodes());
 else     if (name.equals("String_Node_Str"))     updateMessage=getLocaleSpecificMessage(node);
 else     if (name.equals("String_Node_Str")) {
      try {
        timestamp=Long.parseLong(LimeXMLUtils.getText(node.getChildNodes()));
      }
 catch (      NumberFormatException nfx) {
        throw new IOException();
      }
    }
  }
}
Program: 4473
Project: 4473
Buggy source:
public UpdateFileParser(String xml) throws SAXException, IOException {
  if (xml == null || xml.equals("String_Node_Str"))   throw new SAXException("String_Node_Str");
  InputSource inputSource=new InputSource(new StringReader(xml));
  Document d=null;
synchronized (this.parser) {
    parser.parse(inputSource);
    d=parser.getDocument();
  }
  if (d == null)   throw new SAXException("String_Node_Str");
  populateValues(d);
}

Fixed version (ground truth):
public UpdateFileParser(String xml) throws SAXException, IOException {
  if (xml == null || xml.equals("String_Node_Str"))   throw new SAXException("String_Node_Str");
  timestamp=-1l;
  InputSource inputSource=new InputSource(new StringReader(xml));
  Document d=null;
synchronized (this.parser) {
    parser.parse(inputSource);
    d=parser.getDocument();
  }
  if (d == null)   throw new SAXException("String_Node_Str");
  populateValues(d);
}
Program: 4476
Project: 4476
Buggy source:
/** 
 * Ensures that that integrity of the hashes HashMap is valid. This must be done to ensure that older version of LimeWire are started with a valid hashes map.  Previously, entries added to the map were not canonicalized, resulting in multiple downloads thinking they're going to seperate files, but actually going to the same file.
 */
private Map verifyHashes(){
  Map retMap=new HashMap();
  for (Iterator i=hashes.entrySet().iterator(); i.hasNext(); ) {
    Map.Entry entry=(Map.Entry)i.next();
    if (entry.getKey() instanceof URN && entry.getValue() instanceof File) {
      URN urn=(URN)entry.getKey();
      File f=(File)entry.getValue();
      try {
        f=FileUtils.getCanonicalFile(f);
      }
 catch (      IOException ioe) {
      }
      if (!retMap.values().contains(f))       retMap.put(urn,f);
    }
  }
  return retMap;
}

Fixed version (ground truth):
/** 
 * Ensures that that integrity of the hashes HashMap is valid. This must be done to ensure that older version of LimeWire are started with a valid hashes map.  Previously, entries added to the map were not canonicalized, resulting in multiple downloads thinking they're going to seperate files, but actually going to the same file.
 */
private Map verifyHashes(){
  Map retMap=new HashMap();
  for (Iterator i=hashes.entrySet().iterator(); i.hasNext(); ) {
    Map.Entry entry=(Map.Entry)i.next();
    if (entry.getKey() instanceof URN && entry.getValue() instanceof File) {
      URN urn=(URN)entry.getKey();
      File f=(File)entry.getValue();
      try {
        f=FileUtils.getCanonicalFile(f);
        if (!retMap.values().contains(f))         retMap.put(urn,f);
      }
 catch (      IOException ioe) {
      }
    }
  }
  return retMap;
}
Program: 4478
Project: 4478
Buggy source:
/** 
 * Takes a map of File->List<Interval> and returns a new equivalent Map of File->VerifyingFile
 */
private Map transform(Object object){
  Map map=(Map)object;
  Map retMap=new TreeMap(new FileComparator());
  for (Iterator i=map.keySet().iterator(); i.hasNext(); ) {
    Object incompleteFile=i.next();
    Object o=map.get(incompleteFile);
    if (o == null)     continue;
 else {
      Iterator iter=((List)o).iterator();
      VerifyingFile vf=new VerifyingFile(true);
      while (iter.hasNext()) {
        Interval interval=(Interval)iter.next();
        interval.high=interval.high - 1;
        if (interval.high >= interval.low)         vf.addInterval(interval);
      }
      if (incompleteFile instanceof File) {
        File f=(File)incompleteFile;
        try {
          f=FileUtils.getCanonicalFile(f);
        }
 catch (        IOException ignored) {
        }
        retMap.put(f,vf);
      }
    }
  }
  return retMap;
}

Fixed version (ground truth):
/** 
 * Takes a map of File->List<Interval> and returns a new equivalent Map of File->VerifyingFile
 */
private Map transform(Object object){
  Map map=(Map)object;
  Map retMap=new TreeMap(new FileComparator());
  for (Iterator i=map.keySet().iterator(); i.hasNext(); ) {
    Object incompleteFile=i.next();
    Object o=map.get(incompleteFile);
    if (o == null)     continue;
 else {
      Iterator iter=((List)o).iterator();
      VerifyingFile vf=new VerifyingFile(true);
      while (iter.hasNext()) {
        Interval interval=(Interval)iter.next();
        interval.high=interval.high - 1;
        if (interval.high >= interval.low)         vf.addInterval(interval);
      }
      if (incompleteFile instanceof File) {
        File f=(File)incompleteFile;
        try {
          f=FileUtils.getCanonicalFile(f);
          retMap.put(f,vf);
        }
 catch (        IOException ignored) {
        }
      }
    }
  }
  return retMap;
}
Program: 4479
Project: 4479
Buggy source:
/** 
 * Associates the incompleteFile with the VerifyingFile vf. Notifies FileManager about a new Incomplete File.
 */
public synchronized void addEntry(File incompleteFile,VerifyingFile vf){
  boolean ioproblem=false;
  try {
    incompleteFile=FileUtils.getCanonicalFile(incompleteFile);
  }
 catch (  IOException ignored) {
    ioproblem=true;
  }
  blocks.put(incompleteFile,vf);
  if (!ioproblem)   registerIncompleteFile(incompleteFile);
}

Fixed version (ground truth):
/** 
 * Associates the incompleteFile with the VerifyingFile vf. Notifies FileManager about a new Incomplete File.
 */
public synchronized void addEntry(File incompleteFile,VerifyingFile vf) throws IOException {
  incompleteFile=FileUtils.getCanonicalFile(incompleteFile);
  blocks.put(incompleteFile,vf);
  registerIncompleteFile(incompleteFile);
}