Program: 100644
Project: 100644
Buggy source:
/** 
 * Update Job configuration to include new generated files
 */
private void updateList(final Map<URI,URI> changeTable,final Map<URI,URI> conflictTable){
  final URI xmlDitalist=job.tempDir.toURI().resolve("String_Node_Str");
  final Set<URI> hrefTopics=new HashSet<>();
  for (  final FileInfo f : job.getFileInfo()) {
    if (f.isNonConrefTarget) {
      hrefTopics.add(f.uri);
    }
  }
  for (  final FileInfo f : job.getFileInfo()) {
    if (f.isSkipChunk) {
      final URI s=f.uri;
      if (s.getFragment() == null) {
        final Iterator<URI> hrefit=hrefTopics.iterator();
        while (hrefit.hasNext()) {
          final URI ent=hrefit.next();
          if (resolve(job.tempDir,ent).equals(resolve(job.tempDir,s))) {
            hrefit.remove();
          }
        }
      }
 else       if (hrefTopics.contains(s)) {
        hrefTopics.remove(s);
      }
    }
  }
  final Set<URI> topicList=new LinkedHashSet<>(128);
  final Set<URI> oldTopicList=new HashSet<>();
  for (  final FileInfo f : job.getFileInfo()) {
    if (ATTR_FORMAT_VALUE_DITA.equals(f.format)) {
      oldTopicList.add(f.uri);
    }
  }
  for (  final URI hrefTopic : hrefTopics) {
    final URI t=getRelativePath(xmlDitalist,job.tempDir.toURI().resolve(stripFragment(hrefTopic.toString())));
    topicList.add(t);
    if (oldTopicList.contains(t)) {
      oldTopicList.remove(t);
    }
  }
  final Set<URI> chunkedTopicSet=new LinkedHashSet<>(128);
  final Set<URI> chunkedDitamapSet=new LinkedHashSet<>(128);
  final Set<URI> ditamapList=new HashSet<>();
  for (  final FileInfo f : job.getFileInfo()) {
    if (ATTR_FORMAT_VALUE_DITAMAP.equals(f.format)) {
      ditamapList.add(f.uri);
    }
  }
  for (  final Map.Entry<URI,URI> entry : changeTable.entrySet()) {
    final URI oldFile=entry.getKey();
    if (entry.getValue().equals(oldFile)) {
      URI newChunkedFile=entry.getValue();
      newChunkedFile=getRelativePath(xmlDitalist,newChunkedFile);
      final String extName=getExtension(newChunkedFile.getPath());
      if (extName != null && !extName.equalsIgnoreCase(ATTR_FORMAT_VALUE_DITAMAP)) {
        chunkedTopicSet.add(newChunkedFile);
        if (!topicList.contains(newChunkedFile)) {
          topicList.add(newChunkedFile);
          if (oldTopicList.contains(newChunkedFile)) {
            oldTopicList.remove(newChunkedFile);
          }
        }
      }
 else {
        if (!ditamapList.contains(newChunkedFile)) {
          ditamapList.add(newChunkedFile);
          if (oldTopicList.contains(newChunkedFile)) {
            oldTopicList.remove(newChunkedFile);
          }
        }
        chunkedDitamapSet.add(newChunkedFile);
      }
    }
  }
  for (  final URI s : oldTopicList) {
    final File f=new File(job.tempDir.toURI().resolve(s));
    if (f.exists() && !f.delete()) {
      logger.error("String_Node_Str" + f.getAbsolutePath());
    }
  }
  for (  final Map.Entry<URI,URI> entry : changeTable.entrySet()) {
    final URI oldFile=entry.getKey();
    final URI from=entry.getValue();
    if (from.equals(oldFile)) {
      final URI targetPath=conflictTable.get(oldFile);
      if (targetPath != null) {
        final URI target=targetPath;
        if (!new File(target).exists()) {
          URI relativePath=getRelativePath(xmlDitalist,from);
          final URI relativeTargetPath=getRelativePath(xmlDitalist,target);
          if (relativeTargetPath.getPath().indexOf(URI_SEPARATOR) != -1) {
            relativePath2fix.put(relativeTargetPath.getPath(),relativeTargetPath.getPath().substring(0,relativeTargetPath.getPath().lastIndexOf(URI_SEPARATOR) + 1));
          }
          try {
            deleteQuietly(new File(target));
            moveFile(new File(from),new File(target));
          }
 catch (          final IOException e) {
            logger.error("String_Node_Str" + e.getMessage(),e);
          }
          if (topicList.contains(relativePath)) {
            topicList.remove(relativePath);
          }
          if (chunkedTopicSet.contains(relativePath)) {
            chunkedTopicSet.remove(relativePath);
          }
          relativePath=getRelativePath(xmlDitalist,target);
          topicList.add(relativePath);
          chunkedTopicSet.add(relativePath);
        }
 else {
          conflictTable.remove(oldFile);
        }
      }
    }
  }
  final Set<URI> all=new HashSet<>();
  all.addAll(topicList);
  all.addAll(ditamapList);
  all.addAll(chunkedDitamapSet);
  all.addAll(chunkedTopicSet);
  for (  final URI file : oldTopicList) {
    if (!all.contains(file)) {
      job.remove(job.getOrCreateFileInfo(file));
    }
  }
  for (  final URI file : topicList) {
    final FileInfo ff=job.getOrCreateFileInfo(file);
    ff.format=ATTR_FORMAT_VALUE_DITA;
  }
  for (  final URI file : ditamapList) {
    final FileInfo ff=job.getOrCreateFileInfo(file);
    ff.format=ATTR_FORMAT_VALUE_DITAMAP;
  }
  for (  final URI file : chunkedDitamapSet) {
    final FileInfo f=job.getOrCreateFileInfo(file);
    f.format=ATTR_FORMAT_VALUE_DITAMAP;
    f.isResourceOnly=false;
  }
  for (  final URI file : chunkedTopicSet) {
    final FileInfo f=job.getOrCreateFileInfo(file);
    f.format=ATTR_FORMAT_VALUE_DITA;
    f.isResourceOnly=false;
  }
  try {
    job.write();
  }
 catch (  final IOException ex) {
    logger.error(ex.getMessage(),ex);
  }
}

Fixed version (ground truth):
/** 
 * Update Job configuration to include new generated files
 */
private void updateList(final Map<URI,URI> changeTable,final Map<URI,URI> conflictTable){
  final URI xmlDitalist=job.tempDir.toURI().resolve("String_Node_Str");
  final Set<URI> hrefTopics=new HashSet<>();
  for (  final FileInfo f : job.getFileInfo()) {
    if (f.isNonConrefTarget) {
      hrefTopics.add(f.uri);
    }
  }
  for (  final FileInfo f : job.getFileInfo()) {
    if (f.isSkipChunk) {
      final URI s=f.uri;
      if (s.getFragment() == null) {
        final Iterator<URI> hrefit=hrefTopics.iterator();
        while (hrefit.hasNext()) {
          final URI ent=hrefit.next();
          if (job.tempDir.toURI().resolve(ent).equals(job.tempDir.toURI().resolve(s))) {
            hrefit.remove();
          }
        }
      }
 else       if (hrefTopics.contains(s)) {
        hrefTopics.remove(s);
      }
    }
  }
  final Set<URI> topicList=new LinkedHashSet<>(128);
  final Set<URI> oldTopicList=new HashSet<>();
  for (  final FileInfo f : job.getFileInfo()) {
    if (ATTR_FORMAT_VALUE_DITA.equals(f.format)) {
      oldTopicList.add(f.uri);
    }
  }
  for (  final URI hrefTopic : hrefTopics) {
    final URI t=getRelativePath(xmlDitalist,job.tempDir.toURI().resolve(stripFragment(hrefTopic)));
    topicList.add(t);
    if (oldTopicList.contains(t)) {
      oldTopicList.remove(t);
    }
  }
  final Set<URI> chunkedTopicSet=new LinkedHashSet<>(128);
  final Set<URI> chunkedDitamapSet=new LinkedHashSet<>(128);
  final Set<URI> ditamapList=new HashSet<>();
  for (  final FileInfo f : job.getFileInfo()) {
    if (ATTR_FORMAT_VALUE_DITAMAP.equals(f.format)) {
      ditamapList.add(f.uri);
    }
  }
  for (  final Map.Entry<URI,URI> entry : changeTable.entrySet()) {
    final URI oldFile=entry.getKey();
    if (entry.getValue().equals(oldFile)) {
      URI newChunkedFile=entry.getValue();
      newChunkedFile=getRelativePath(xmlDitalist,newChunkedFile);
      final String extName=getExtension(newChunkedFile.getPath());
      if (extName != null && !extName.equalsIgnoreCase(ATTR_FORMAT_VALUE_DITAMAP)) {
        chunkedTopicSet.add(newChunkedFile);
        if (!topicList.contains(newChunkedFile)) {
          topicList.add(newChunkedFile);
          if (oldTopicList.contains(newChunkedFile)) {
            oldTopicList.remove(newChunkedFile);
          }
        }
      }
 else {
        if (!ditamapList.contains(newChunkedFile)) {
          ditamapList.add(newChunkedFile);
          if (oldTopicList.contains(newChunkedFile)) {
            oldTopicList.remove(newChunkedFile);
          }
        }
        chunkedDitamapSet.add(newChunkedFile);
      }
    }
  }
  for (  final URI s : oldTopicList) {
    final File f=new File(job.tempDir.toURI().resolve(s));
    if (f.exists() && !f.delete()) {
      logger.error("String_Node_Str" + f.getAbsolutePath());
    }
  }
  for (  final Map.Entry<URI,URI> entry : changeTable.entrySet()) {
    final URI oldFile=entry.getKey();
    final URI from=entry.getValue();
    if (from.equals(oldFile)) {
      final URI targetPath=conflictTable.get(oldFile);
      if (targetPath != null) {
        final URI target=targetPath;
        if (!new File(target).exists()) {
          URI relativePath=getRelativePath(xmlDitalist,from);
          final URI relativeTargetPath=getRelativePath(xmlDitalist,target);
          if (relativeTargetPath.getPath().contains(URI_SEPARATOR)) {
            relativePath2fix.put(relativeTargetPath.getPath(),relativeTargetPath.getPath().substring(0,relativeTargetPath.getPath().lastIndexOf(URI_SEPARATOR) + 1));
          }
          try {
            deleteQuietly(new File(target));
            moveFile(new File(from),new File(target));
          }
 catch (          final IOException e) {
            logger.error("String_Node_Str" + e.getMessage(),e);
          }
          if (topicList.contains(relativePath)) {
            topicList.remove(relativePath);
          }
          if (chunkedTopicSet.contains(relativePath)) {
            chunkedTopicSet.remove(relativePath);
          }
          relativePath=getRelativePath(xmlDitalist,target);
          topicList.add(relativePath);
          chunkedTopicSet.add(relativePath);
        }
 else {
          conflictTable.remove(oldFile);
        }
      }
    }
  }
  final Set<URI> all=new HashSet<>();
  all.addAll(topicList);
  all.addAll(ditamapList);
  all.addAll(chunkedDitamapSet);
  all.addAll(chunkedTopicSet);
  for (  final URI file : oldTopicList) {
    if (!all.contains(file)) {
      job.remove(job.getOrCreateFileInfo(file));
    }
  }
  for (  final URI file : topicList) {
    final FileInfo ff=job.getOrCreateFileInfo(file);
    ff.format=ATTR_FORMAT_VALUE_DITA;
  }
  for (  final URI file : ditamapList) {
    final FileInfo ff=job.getOrCreateFileInfo(file);
    ff.format=ATTR_FORMAT_VALUE_DITAMAP;
  }
  for (  final URI file : chunkedDitamapSet) {
    final FileInfo f=job.getOrCreateFileInfo(file);
    f.format=ATTR_FORMAT_VALUE_DITAMAP;
    f.isResourceOnly=false;
  }
  for (  final URI file : chunkedTopicSet) {
    final FileInfo f=job.getOrCreateFileInfo(file);
    f.format=ATTR_FORMAT_VALUE_DITA;
    f.isResourceOnly=false;
  }
  try {
    job.write();
  }
 catch (  final IOException ex) {
    logger.error(ex.getMessage(),ex);
  }
}