Program: 70969
Project: 70969
Buggy source:
public File cache(URIx uri,File cacheFile,FileTransferMonitor monitor) throws FileSystemException {
  File tmpCacheFile=new File(cacheFile.getAbsolutePath() + TMP_EXTENSION);
  FileObject localTempFile=manager.resolveFile(tmpCacheFile.getAbsolutePath());
  FileObject localCacheFile=manager.resolveFile(cacheFile.getAbsolutePath());
  FileObject remoteFile=null;
  setAuthenticator(fsOpts,null);
  setIdentityFactory(fsOpts,null);
  boolean cancel=false;
  while (remoteFile == null && cancel == false) {
    remoteFile=resolveRemote(uri);
  }
  if (remoteFile == null || !remoteFile.exists()) {
    throw new FileSystemException("String_Node_Str" + uri.toString() + "String_Node_Str",new FileNotFoundException("String_Node_Str" + uri.toString() + "String_Node_Str"));
  }
  if (monitor != null) {
    monitor.monitor(localTempFile,remoteFile,-1,cacheFile.getName());
    monitor.start();
    monitor.fireStartEvent(localTempFile);
  }
  try {
    if (remoteFile.isFile()) {
      localTempFile.copyFrom(remoteFile,Selectors.SELECT_SELF);
    }
 else     if (remoteFile.isFolder()) {
      localTempFile.copyFrom(remoteFile,Selectors.SELECT_SELF_AND_CHILDREN);
    }
    if (monitor != null) {
      monitor.fireCompleteEvent(localTempFile);
    }
  }
 catch (  Exception e) {
    localTempFile.delete();
    throw new RuntimeException("String_Node_Str" + remoteFile.getURL() + "String_Node_Str"+ localTempFile.getURL(),e);
  }
 finally {
    localTempFile.close();
    remoteFile.close();
    if (monitor != null) {
      monitor.release(localTempFile);
      monitor.stop();
    }
  }
  try {
    if (tmpCacheFile.isDirectory()) {
      SafeFileUtils.moveDirectory(tmpCacheFile,cacheFile);
    }
 else {
      SafeFileUtils.moveFile(tmpCacheFile,cacheFile);
    }
  }
 catch (  Exception e) {
    localCacheFile.delete();
    throw new RuntimeException("String_Node_Str" + "String_Node_Str" + localCacheFile.getURL(),e);
  }
  return cacheFile;
}

Fixed version (ground truth):
public File cache(URIx uri,File cacheFile,FileTransferMonitor monitor) throws FileSystemException {
  File tmpCacheFile=new File(cacheFile.getAbsolutePath() + TMP_EXTENSION);
  URIx cacheURI=new URIx(cacheFile.getAbsoluteFile());
  URIx tmpCacheURI=new URIx(tmpCacheFile.getAbsoluteFile());
  FileObject localTempFile=manager.resolveFile(tmpCacheURI.toString(true));
  FileObject localCacheFile=manager.resolveFile(cacheURI.toString(true));
  FileObject remoteFile=null;
  setAuthenticator(fsOpts,null);
  setIdentityFactory(fsOpts,null);
  boolean cancel=false;
  while (remoteFile == null && cancel == false) {
    remoteFile=resolveRemote(uri);
  }
  if (remoteFile == null || !remoteFile.exists()) {
    throw new FileSystemException("String_Node_Str" + uri.toString() + "String_Node_Str",new FileNotFoundException("String_Node_Str" + uri.toString() + "String_Node_Str"));
  }
  if (monitor != null) {
    monitor.monitor(localTempFile,remoteFile,-1,cacheFile.getName());
    monitor.start();
    monitor.fireStartEvent(localTempFile);
  }
  try {
    if (remoteFile.isFile()) {
      localTempFile.copyFrom(remoteFile,Selectors.SELECT_SELF);
    }
 else     if (remoteFile.isFolder()) {
      localTempFile.copyFrom(remoteFile,Selectors.SELECT_SELF_AND_CHILDREN);
    }
    if (monitor != null) {
      monitor.fireCompleteEvent(localTempFile);
    }
  }
 catch (  Exception e) {
    localTempFile.delete();
    throw new RuntimeException("String_Node_Str" + remoteFile.getURL() + "String_Node_Str"+ localTempFile.getURL(),e);
  }
 finally {
    localTempFile.close();
    remoteFile.close();
    if (monitor != null) {
      monitor.release(localTempFile);
      monitor.stop();
    }
  }
  try {
    if (tmpCacheFile.isDirectory()) {
      SafeFileUtils.moveDirectory(tmpCacheFile,cacheFile);
    }
 else {
      SafeFileUtils.moveFile(tmpCacheFile,cacheFile);
    }
  }
 catch (  Exception e) {
    localCacheFile.delete();
    throw new RuntimeException("String_Node_Str" + "String_Node_Str" + localCacheFile.getURL(),e);
  }
  return cacheFile;
}