Program: 162552
Project: 162552
Buggy source:
/** 
 * Starts copy of file Supports :   {@link File},   {@link jcifs.smb.SmbFile},   {@link DocumentFile}
 * @throws IOException
 */
private void startCopy() throws IOException {
  FileInputStream inputStream=null;
  FileOutputStream outputStream=null;
  FileChannel inChannel=null;
  FileChannel outChannel=null;
  BufferedInputStream bufferedInputStream=null;
  BufferedOutputStream bufferedOutputStream=null;
  try {
    if (mSourceFile.isOtgFile()) {
      ContentResolver contentResolver=mContext.getContentResolver();
      DocumentFile documentSourceFile=RootHelper.getDocumentFile(mSourceFile.getPath(),mContext,false);
      bufferedInputStream=new BufferedInputStream(contentResolver.openInputStream(documentSourceFile.getUri()),DEFAULT_BUFFER_SIZE);
    }
 else     if (mSourceFile.isSmb()) {
      bufferedInputStream=new BufferedInputStream(mSourceFile.getInputStream(),DEFAULT_BUFFER_SIZE);
    }
 else {
      inChannel=new RandomAccessFile(new File(mSourceFile.getPath()),"String_Node_Str").getChannel();
    }
    if (mTargetFile.isOtgFile()) {
      ContentResolver contentResolver=mContext.getContentResolver();
      DocumentFile documentTargetFile=RootHelper.getDocumentFile(mTargetFile.getPath(),mContext,true);
      bufferedOutputStream=new BufferedOutputStream(contentResolver.openOutputStream(documentTargetFile.getUri()),DEFAULT_BUFFER_SIZE);
    }
 else     if (mTargetFile.isSmb()) {
      bufferedOutputStream=new BufferedOutputStream(mTargetFile.getOutputStream(mContext),DEFAULT_BUFFER_SIZE);
    }
 else {
      outChannel=new RandomAccessFile(new File(mTargetFile.getPath()),"String_Node_Str").getChannel();
    }
    if (bufferedInputStream != null) {
      if (bufferedOutputStream != null)       copyFile(bufferedInputStream,bufferedOutputStream);
 else       if (outChannel != null) {
        copyFile(bufferedInputStream,outChannel);
      }
    }
 else     if (inChannel != null) {
      if (bufferedOutputStream != null)       copyFile(inChannel,bufferedOutputStream);
 else       if (outChannel != null)       copyFile(inChannel,outChannel);
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
    Log.d(getClass().getSimpleName(),"String_Node_Str");
    throw new IOException();
  }
 finally {
    try {
      if (inChannel != null)       inChannel.close();
      if (outChannel != null)       outChannel.close();
      if (inputStream != null)       inputStream.close();
      if (outputStream != null)       outputStream.close();
      if (bufferedInputStream != null)       bufferedInputStream.close();
      if (bufferedOutputStream != null)       bufferedOutputStream.close();
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
/** 
 * Starts copy of file Supports :   {@link File},   {@link jcifs.smb.SmbFile},   {@link DocumentFile}
 * @throws IOException
 */
private void startCopy() throws IOException {
  FileInputStream inputStream=null;
  FileOutputStream outputStream=null;
  FileChannel inChannel=null;
  FileChannel outChannel=null;
  BufferedInputStream bufferedInputStream=null;
  BufferedOutputStream bufferedOutputStream=null;
  try {
    if (mSourceFile.isOtgFile()) {
      ContentResolver contentResolver=mContext.getContentResolver();
      DocumentFile documentSourceFile=RootHelper.getDocumentFile(mSourceFile.getPath(),mContext,false);
      bufferedInputStream=new BufferedInputStream(contentResolver.openInputStream(documentSourceFile.getUri()),DEFAULT_BUFFER_SIZE);
    }
 else     if (mSourceFile.isSmb()) {
      bufferedInputStream=new BufferedInputStream(mSourceFile.getInputStream(),DEFAULT_BUFFER_SIZE);
    }
 else {
      File file=new File(mSourceFile.getPath());
      if (FileUtil.isReadable(file)) {
        inChannel=new RandomAccessFile(file,"String_Node_Str").getChannel();
      }
 else {
        ContentResolver contentResolver=mContext.getContentResolver();
        DocumentFile documentSourceFile=FileUtil.getDocumentFile(file,mSourceFile.isDirectory(),mContext);
        bufferedInputStream=new BufferedInputStream(contentResolver.openInputStream(documentSourceFile.getUri()),DEFAULT_BUFFER_SIZE);
      }
    }
    if (mTargetFile.isOtgFile()) {
      ContentResolver contentResolver=mContext.getContentResolver();
      DocumentFile documentTargetFile=RootHelper.getDocumentFile(mTargetFile.getPath(),mContext,true);
      bufferedOutputStream=new BufferedOutputStream(contentResolver.openOutputStream(documentTargetFile.getUri()),DEFAULT_BUFFER_SIZE);
    }
 else     if (mTargetFile.isSmb()) {
      bufferedOutputStream=new BufferedOutputStream(mTargetFile.getOutputStream(mContext),DEFAULT_BUFFER_SIZE);
    }
 else {
      File file=new File(mTargetFile.getPath());
      if (FileUtil.isWritable(file)) {
        outChannel=new RandomAccessFile(file,"String_Node_Str").getChannel();
      }
 else {
        ContentResolver contentResolver=mContext.getContentResolver();
        DocumentFile documentTargetFile=FileUtil.getDocumentFile(file,mTargetFile.isDirectory(),mContext);
        bufferedOutputStream=new BufferedOutputStream(contentResolver.openOutputStream(documentTargetFile.getUri()),DEFAULT_BUFFER_SIZE);
      }
    }
    if (bufferedInputStream != null) {
      if (bufferedOutputStream != null)       copyFile(bufferedInputStream,bufferedOutputStream);
 else       if (outChannel != null) {
        copyFile(bufferedInputStream,outChannel);
      }
    }
 else     if (inChannel != null) {
      if (bufferedOutputStream != null)       copyFile(inChannel,bufferedOutputStream);
 else       if (outChannel != null)       copyFile(inChannel,outChannel);
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
    Log.d(getClass().getSimpleName(),"String_Node_Str");
    throw new IOException();
  }
 finally {
    try {
      if (inChannel != null)       inChannel.close();
      if (outChannel != null)       outChannel.close();
      if (inputStream != null)       inputStream.close();
      if (outputStream != null)       outputStream.close();
      if (bufferedInputStream != null)       bufferedInputStream.close();
      if (bufferedOutputStream != null)       bufferedOutputStream.close();
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
}