Program: 3827
Project: 3827
Buggy source:
/** 
 * Create the FD with or without URNs or XML. Step 1 of loading a filedesc. Then proceed to either step 2 (calculate URNs if none exist) or step 3 (check if dangerous & load XML)
 */
private void startLoadingFileDesc(final File file,Set<URN> urns,final List<? extends LimeXMLDocument> metadata,final FileDesc oldFileDesc,final PendingFuture task){
  final FileDesc fd=createAndAddFileDesc(file,metadata,urns,oldFileDesc,task);
  if (fd != null) {
    if (urns.isEmpty()) {
      ListeningFuture<Set<URN>> urnFuture=urnCache.calculateAndCacheUrns(file);
      setFutureForFile(file,urnFuture);
      LOG.debugf("String_Node_Str",file);
      broadcastQueued(file);
      urnFuture.addFutureListener(new EventListener<FutureEvent<Set<URN>>>(){
        @Override public void handleEvent(        FutureEvent<Set<URN>> event){
          LOG.debugf("String_Node_Str",file);
          removeFutureForFile(file);
          if (contains(fd)) {
            addUrnsToFileDesc(fd,metadata,event,task,oldFileDesc);
          }
          broadcastFinished(file);
        }
      }
);
    }
 else {
      boolean safe=getLibraryData().isFileSafe(fd.getSHA1Urn().toString());
      boolean loadedXML=!fd.getLimeXMLDocuments().isEmpty();
      boolean allowsXML=xmlController.canConstructXml(fd);
      if (safe && (loadedXML || !allowsXML)) {
        LOG.debugf("String_Node_Str",file);
        removeFutureForFile(file);
        task.set(fd);
      }
 else {
        LOG.debugf("String_Node_Str",file);
        broadcastQueued(file);
        rwLock.writeLock().lock();
        try {
          LOG.debugf("String_Node_Str",fd.getFile());
          setFutureForFile(fd.getFile(),diskIoService.submit(new Runnable(){
            @Override public void run(){
              broadcastProcessing(fd.getFile());
              LOG.debugf("String_Node_Str",fd.getFile());
              removeFutureForFile(fd.getFile());
              if (contains(fd)) {
                finishLoadingFileDesc(fd,metadata,task,false,oldFileDesc);
              }
              broadcastFinished(file);
            }
          }
));
        }
  finally {
          rwLock.writeLock().unlock();
        }
      }
    }
  }
 else {
    LOG.debugf("String_Node_Str",file);
  }
}

Fixed version (ground truth):
/** 
 * Create the FD with or without URNs or XML. Step 1 of loading a filedesc. Then proceed to either step 2 (calculate URNs if none exist) or step 3 (check if dangerous & load XML)
 */
private void startLoadingFileDesc(final File file,Set<URN> urns,final List<? extends LimeXMLDocument> metadata,final FileDesc oldFileDesc,final PendingFuture task){
  final FileDesc fd=createAndAddFileDesc(file,metadata,urns,oldFileDesc,task);
  if (fd != null) {
    if (urns.isEmpty()) {
      ListeningFuture<Set<URN>> urnFuture=urnCache.calculateAndCacheUrns(file);
      setFutureForFile(file,urnFuture);
      LOG.debugf("String_Node_Str",file);
      broadcastQueued(file);
      urnFuture.addFutureListener(new EventListener<FutureEvent<Set<URN>>>(){
        @Override public void handleEvent(        FutureEvent<Set<URN>> event){
          LOG.debugf("String_Node_Str",file);
          removeFutureForFile(file);
          if (contains(fd)) {
            addUrnsToFileDesc(fd,metadata,event,task,oldFileDesc);
          }
          if (event.getType() != FutureEvent.Type.CANCELLED) {
            broadcastFinished(file);
          }
        }
      }
);
    }
 else {
      boolean safe=getLibraryData().isFileSafe(fd.getSHA1Urn().toString());
      boolean loadedXML=!fd.getLimeXMLDocuments().isEmpty();
      boolean allowsXML=xmlController.canConstructXml(fd);
      if (safe && (loadedXML || !allowsXML)) {
        LOG.debugf("String_Node_Str",file);
        removeFutureForFile(file);
        task.set(fd);
      }
 else {
        LOG.debugf("String_Node_Str",file);
        broadcastQueued(file);
        rwLock.writeLock().lock();
        try {
          LOG.debugf("String_Node_Str",fd.getFile());
          setFutureForFile(fd.getFile(),diskIoService.submit(new Runnable(){
            @Override public void run(){
              broadcastProcessing(fd.getFile());
              LOG.debugf("String_Node_Str",fd.getFile());
              removeFutureForFile(fd.getFile());
              if (contains(fd)) {
                finishLoadingFileDesc(fd,metadata,task,false,oldFileDesc);
              }
              broadcastFinished(file);
            }
          }
));
        }
  finally {
          rwLock.writeLock().unlock();
        }
      }
    }
  }
 else {
    LOG.debugf("String_Node_Str",file);
  }
}