Program: 116878
Project: 116878
Buggy source:
@Override public boolean DownloadFil(IoEngine_xrg_downloadFil xrg){
  IoStream trg_stream=null;
  java.io.BufferedInputStream src_stream=null;
  java.net.URL src_url=null;
  HttpURLConnection src_conn=null;
  if (user_agent_needs_resetting) {
    user_agent_needs_resetting=false;
    System.setProperty("String_Node_Str","String_Node_Str");
  }
  boolean exists=Io_mgr.Instance.ExistsDir(xrg.Trg().OwnerDir());
  Gfo_usr_dlg prog_dlg=null;
  String src_str=xrg.Src();
  Io_download_fmt xfer_fmt=xrg.Download_fmt();
  prog_dlg=xfer_fmt.Usr_dlg();
  if (!Web_access_enabled) {
    if (prog_dlg != null) {
      if (session_fil == null)       session_fil=prog_dlg.Log_wkr().Session_dir().GenSubFil("String_Node_Str");
      prog_dlg.Log_wkr().Log_msg_to_url_fmt(session_fil,"String_Node_Str",xrg.Src(),xrg.Trg().Raw());
    }
    return false;
  }
  try {
    trg_stream=Io_mgr.Instance.OpenStreamWrite(xrg.Trg());
    src_url=new java.net.URL(src_str);
    src_conn=(HttpURLConnection)src_url.openConnection();
    String user_agent=xrg.User_agent();
    if (user_agent != null)     src_conn.setRequestProperty("String_Node_Str",user_agent);
    long content_length=Long_.parse_or(src_conn.getHeaderField("String_Node_Str"),IoItmFil.Size_invalid_int);
    xrg.Src_content_length_(content_length);
    if (xrg.Src_last_modified_query())     xrg.Src_last_modified_(DateAdp_.unixtime_lcl_ms_(src_conn.getLastModified()));
    if (xrg.Exec_meta_only())     return true;
    src_stream=new java.io.BufferedInputStream(src_conn.getInputStream());
    if (!exists) {
      Io_mgr.Instance.CreateDir(xrg.Trg().OwnerDir());
    }
    byte[] download_bfr=new byte[Download_bfr_len];
    xfer_fmt.Bgn(content_length);
    int count=0;
    while ((count=src_stream.read(download_bfr,0,Download_bfr_len)) != -1) {
      if (xrg.Prog_cancel()) {
        src_stream.close();
        trg_stream.Rls();
        Io_mgr.Instance.DeleteFil(xrg.Trg());
      }
      xfer_fmt.Prog(count);
      trg_stream.Write(download_bfr,0,count);
    }
    if (prog_dlg != null) {
      xfer_fmt.Term();
      if (session_fil == null)       session_fil=prog_dlg.Log_wkr().Session_dir().GenSubFil("String_Node_Str");
      prog_dlg.Log_wkr().Log_msg_to_url_fmt(session_fil,"String_Node_Str",src_str,xrg.Trg().Raw());
    }
    return true;
  }
 catch (  Exception exc) {
    xrg.Rslt_err_(exc);
    if (Type_adp_.Eq_typeSafe(exc,java.net.UnknownHostException.class))     xrg.Rslt_(IoEngine_xrg_downloadFil.Rslt_fail_host_not_found);
 else     if (Type_adp_.Eq_typeSafe(exc,java.io.FileNotFoundException.class))     xrg.Rslt_(IoEngine_xrg_downloadFil.Rslt_fail_file_not_found);
 else     xrg.Rslt_(IoEngine_xrg_downloadFil.Rslt_fail_unknown);
    if (prog_dlg != null && !xrg.Prog_cancel()) {
      if (session_fil == null)       session_fil=prog_dlg.Log_wkr().Session_dir().GenSubFil("String_Node_Str");
      prog_dlg.Log_wkr().Log_msg_to_url_fmt(session_fil,"String_Node_Str",src_str,xrg.Trg().Raw(),Err_.Message_lang(exc));
    }
    if (trg_stream != null) {
      try {
        trg_stream.Rls();
        DeleteFil_api(IoEngine_xrg_deleteFil.new_(xrg.Trg()));
      }
 catch (      Exception e2) {
        Err_.Noop(e2);
      }
    }
    return false;
  }
 finally {
    xrg.Prog_running_(false);
    try {
      if (src_stream != null)       src_stream.close();
      if (src_conn != null)       src_conn.disconnect();
      src_conn.getInputStream().close();
    }
 catch (    Exception exc) {
      Err_.Noop(exc);
    }
    if (trg_stream != null)     trg_stream.Rls();
  }
}

Fixed version (ground truth):
@Override public boolean DownloadFil(IoEngine_xrg_downloadFil xrg){
  IoStream trg_stream=null;
  java.io.BufferedInputStream src_stream=null;
  java.net.URL src_url=null;
  HttpURLConnection src_conn=null;
  if (user_agent_needs_resetting) {
    user_agent_needs_resetting=false;
    System.setProperty("String_Node_Str","String_Node_Str");
  }
  boolean exists=Io_mgr.Instance.ExistsDir(xrg.Trg().OwnerDir());
  Gfo_usr_dlg prog_dlg=null;
  String src_str=xrg.Src();
  Io_download_fmt xfer_fmt=xrg.Download_fmt();
  prog_dlg=xfer_fmt.Usr_dlg();
  if (!Web_access_enabled) {
    if (prog_dlg != null) {
      if (session_fil == null)       session_fil=prog_dlg.Log_wkr().Session_dir().GenSubFil("String_Node_Str");
      prog_dlg.Log_wkr().Log_msg_to_url_fmt(session_fil,"String_Node_Str",xrg.Src(),xrg.Trg().Raw());
    }
    return false;
  }
  try {
    trg_stream=Io_mgr.Instance.OpenStreamWrite(xrg.Trg());
    src_url=new java.net.URL(src_str);
    src_conn=(HttpURLConnection)src_url.openConnection();
    String user_agent=xrg.User_agent();
    if (user_agent != null)     src_conn.setRequestProperty("String_Node_Str",user_agent);
    long content_length=Long_.parse_or(src_conn.getHeaderField("String_Node_Str"),IoItmFil.Size_invalid_int);
    xrg.Src_content_length_(content_length);
    if (xrg.Src_last_modified_query())     xrg.Src_last_modified_(DateAdp_.unixtime_lcl_ms_(src_conn.getLastModified()));
    if (xrg.Exec_meta_only())     return true;
    src_stream=new java.io.BufferedInputStream(src_conn.getInputStream());
    if (!exists) {
      Io_mgr.Instance.CreateDir(xrg.Trg().OwnerDir());
    }
    byte[] download_bfr=new byte[Download_bfr_len];
    xfer_fmt.Bgn(content_length);
    int count=0;
    while ((count=src_stream.read(download_bfr,0,Download_bfr_len)) != -1) {
      if (xrg.Prog_cancel()) {
        src_stream.close();
        trg_stream.Rls();
        Io_mgr.Instance.DeleteFil(xrg.Trg());
      }
      xfer_fmt.Prog(count);
      trg_stream.Write(download_bfr,0,count);
    }
    if (prog_dlg != null) {
      xfer_fmt.Term();
      if (session_fil == null)       session_fil=prog_dlg.Log_wkr().Session_dir().GenSubFil("String_Node_Str");
      prog_dlg.Log_wkr().Log_msg_to_url_fmt(session_fil,"String_Node_Str",src_str,xrg.Trg().Raw());
    }
    return true;
  }
 catch (  Exception exc) {
    xrg.Rslt_err_(exc);
    if (Type_adp_.Eq_typeSafe(exc,java.net.UnknownHostException.class))     xrg.Rslt_(IoEngine_xrg_downloadFil.Rslt_fail_host_not_found);
 else     if (Type_adp_.Eq_typeSafe(exc,java.io.FileNotFoundException.class))     xrg.Rslt_(IoEngine_xrg_downloadFil.Rslt_fail_file_not_found);
 else     xrg.Rslt_(IoEngine_xrg_downloadFil.Rslt_fail_unknown);
    if (prog_dlg != null && !xrg.Prog_cancel()) {
      if (session_fil == null)       session_fil=prog_dlg.Log_wkr().Session_dir().GenSubFil("String_Node_Str");
      prog_dlg.Log_wkr().Log_msg_to_url_fmt(session_fil,"String_Node_Str",src_str,xrg.Trg().Raw(),Err_.Message_lang(exc));
    }
    if (trg_stream != null) {
      try {
        trg_stream.Rls();
        DeleteFil_api(IoEngine_xrg_deleteFil.new_(xrg.Trg()));
      }
 catch (      Exception e2) {
        Err_.Noop(e2);
      }
    }
    return false;
  }
 finally {
    xrg.Prog_running_(false);
    try {
      if (src_stream != null)       src_stream.close();
      if (src_conn != null) {
        src_conn.disconnect();
        src_conn.getInputStream().close();
      }
    }
 catch (    Exception exc) {
      Err_.Noop(exc);
    }
    if (trg_stream != null)     trg_stream.Rls();
  }
}