Program: 100659
Project: 100659
Buggy source:
/** 
 * Update Job configuration to include new generated files
 */
private void updateList(final Map<String,String> changeTable,final Map<String,String> conflictTable){
  final URI xmlDitalist=new File(job.tempDir,"String_Node_Str").toURI();
  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 String s=f.file.getPath();
      if (!StringUtils.isEmptyString(s) && getFragment(s) == null) {
        final Iterator<URI> hrefit=hrefTopics.iterator();
        while (hrefit.hasNext()) {
          final URI ent=hrefit.next();
          if (resolve(job.tempDir.getAbsoluteFile(),ent).equals(resolve(job.tempDir.getAbsolutePath(),s))) {
            hrefit.remove();
          }
        }
      }
 else       if (!StringUtils.isEmptyString(s) && 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<String,String> entry : changeTable.entrySet()) {
    final String oldFile=entry.getKey();
    if (entry.getValue().equals(oldFile)) {
      URI newChunkedFile=new File(entry.getValue()).toURI();
      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<String,String> entry : changeTable.entrySet()) {
    final String oldFile=entry.getKey();
    if (entry.getValue().equals(oldFile)) {
      final String targetPath=conflictTable.get(entry.getKey());
      if (targetPath != null) {
        final URI target=new File(targetPath).toURI();
        if (!new File(target).exists()) {
          final URI from=new File(entry.getValue()).toURI();
          URI relativePath=getRelativePath(xmlDitalist,from);
          final URI relativeTargetPath=getRelativePath(xmlDitalist,target);
          if (relativeTargetPath.getPath().lastIndexOf(File.separator) != -1) {
            relativePath2fix.put(relativeTargetPath.getPath(),relativeTargetPath.getPath().substring(0,relativeTargetPath.getPath().lastIndexOf(File.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(entry.getKey());
        }
      }
    }
  }
  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<String,String> changeTable,final Map<String,String> conflictTable){
  final URI xmlDitalist=new File(job.tempDir,"String_Node_Str").toURI();
  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<String,String> entry : changeTable.entrySet()) {
    final String oldFile=entry.getKey();
    if (entry.getValue().equals(oldFile)) {
      URI newChunkedFile=new File(entry.getValue()).toURI();
      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<String,String> entry : changeTable.entrySet()) {
    final String oldFile=entry.getKey();
    if (entry.getValue().equals(oldFile)) {
      final String targetPath=conflictTable.get(entry.getKey());
      if (targetPath != null) {
        final URI target=new File(targetPath).toURI();
        if (!new File(target).exists()) {
          final URI from=new File(entry.getValue()).toURI();
          URI relativePath=getRelativePath(xmlDitalist,from);
          final URI relativeTargetPath=getRelativePath(xmlDitalist,target);
          if (relativeTargetPath.getPath().lastIndexOf(File.separator) != -1) {
            relativePath2fix.put(relativeTargetPath.getPath(),relativeTargetPath.getPath().substring(0,relativeTargetPath.getPath().lastIndexOf(File.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(entry.getKey());
        }
      }
    }
  }
  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);
  }
}