Program: 152314
Project: 152314
Buggy source:
/** 
 * Execute command.
 */
public void execute(Connection connection,FtpRequest request,FtpSessionImpl session,FtpReplyOutput out) throws IOException, FtpException {
  try {
    long skipLen=session.getFileOffset();
    FtpServerContext serverContext=connection.getServerContext();
    String fileName=request.getArgument();
    if (fileName == null) {
      out.write(FtpReplyUtil.translate(session,FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS,"String_Node_Str",null));
      return;
    }
    Ftplet ftpletContainer=serverContext.getFtpletContainer();
    FtpletEnum ftpletRet;
    try {
      ftpletRet=ftpletContainer.onDownloadStart(session,request,out);
    }
 catch (    Exception e) {
      LOG.debug("String_Node_Str",e);
      ftpletRet=FtpletEnum.RET_DISCONNECT;
    }
    if (ftpletRet == FtpletEnum.RET_SKIP) {
      return;
    }
 else     if (ftpletRet == FtpletEnum.RET_DISCONNECT) {
      serverContext.getConnectionManager().closeConnection(connection);
      return;
    }
    FileObject file=null;
    try {
      file=session.getFileSystemView().getFileObject(fileName);
    }
 catch (    Exception ex) {
      LOG.debug("String_Node_Str",ex);
    }
    if (file == null) {
      out.write(FtpReplyUtil.translate(session,FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN,"String_Node_Str",fileName));
      return;
    }
    fileName=file.getFullName();
    if (!file.doesExist()) {
      out.write(FtpReplyUtil.translate(session,FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN,"String_Node_Str",fileName));
      return;
    }
    if (!file.isFile()) {
      out.write(FtpReplyUtil.translate(session,FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN,"String_Node_Str",fileName));
      return;
    }
    if (!file.hasReadPermission()) {
      out.write(FtpReplyUtil.translate(session,FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN,"String_Node_Str",fileName));
      return;
    }
    out.write(FtpReplyUtil.translate(session,FtpReply.REPLY_150_FILE_STATUS_OKAY,"String_Node_Str",null));
    boolean failure=false;
    InputStream is=null;
    DataConnection dataConnection;
    try {
      dataConnection=session.getDataConnection().openConnection();
    }
 catch (    Exception e) {
      LOG.debug("String_Node_Str",e);
      out.write(FtpReplyUtil.translate(session,FtpReply.REPLY_425_CANT_OPEN_DATA_CONNECTION,"String_Node_Str",null));
      return;
    }
    try {
      is=openInputStream(connection,session,file,skipLen);
      long transSz=dataConnection.transferToClient(is);
      String userName=session.getUser().getName();
      LOG.info("String_Node_Str" + userName + "String_Node_Str"+ fileName);
      ServerFtpStatistics ftpStat=(ServerFtpStatistics)serverContext.getFtpStatistics();
      if (ftpStat != null) {
        ftpStat.setDownload(connection,file,transSz);
      }
    }
 catch (    SocketException ex) {
      LOG.debug("String_Node_Str",ex);
      failure=true;
      out.write(FtpReplyUtil.translate(session,FtpReply.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED,"String_Node_Str",fileName));
    }
catch (    IOException ex) {
      LOG.debug("String_Node_Str",ex);
      failure=true;
      out.write(FtpReplyUtil.translate(session,FtpReply.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN,"String_Node_Str",fileName));
    }
 finally {
      IoUtils.close(is);
    }
    if (!failure) {
      out.write(FtpReplyUtil.translate(session,FtpReply.REPLY_226_CLOSING_DATA_CONNECTION,"String_Node_Str",fileName));
      try {
        ftpletRet=ftpletContainer.onDownloadEnd(session,request,out);
      }
 catch (      Exception e) {
        LOG.debug("String_Node_Str",e);
        ftpletRet=FtpletEnum.RET_DISCONNECT;
      }
      if (ftpletRet == FtpletEnum.RET_DISCONNECT) {
        serverContext.getConnectionManager().closeConnection(connection);
        return;
      }
    }
  }
  finally {
    session.resetState();
    session.getDataConnection().closeDataConnection();
  }
}

Fixed version (ground truth):
/** 
 * Execute command.
 */
public void execute(Connection connection,FtpRequest request,FtpSessionImpl session,FtpReplyOutput out) throws IOException, FtpException {
  try {
    long skipLen=session.getFileOffset();
    FtpServerContext serverContext=connection.getServerContext();
    String fileName=request.getArgument();
    if (fileName == null) {
      out.write(FtpReplyUtil.translate(session,FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS,"String_Node_Str",null));
      return;
    }
    Ftplet ftpletContainer=serverContext.getFtpletContainer();
    FtpletEnum ftpletRet;
    try {
      ftpletRet=ftpletContainer.onDownloadStart(session,request,out);
    }
 catch (    Exception e) {
      LOG.debug("String_Node_Str",e);
      ftpletRet=FtpletEnum.RET_DISCONNECT;
    }
    if (ftpletRet == FtpletEnum.RET_SKIP) {
      return;
    }
 else     if (ftpletRet == FtpletEnum.RET_DISCONNECT) {
      serverContext.getConnectionManager().closeConnection(connection);
      return;
    }
    FileObject file=null;
    try {
      file=session.getFileSystemView().getFileObject(fileName);
    }
 catch (    Exception ex) {
      LOG.debug("String_Node_Str",ex);
    }
    if (file == null) {
      out.write(FtpReplyUtil.translate(session,FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN,"String_Node_Str",fileName));
      return;
    }
    fileName=file.getFullName();
    if (!file.doesExist()) {
      out.write(FtpReplyUtil.translate(session,FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN,"String_Node_Str",fileName));
      return;
    }
    if (!file.isFile()) {
      out.write(FtpReplyUtil.translate(session,FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN,"String_Node_Str",fileName));
      return;
    }
    if (!file.hasReadPermission()) {
      out.write(FtpReplyUtil.translate(session,FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN,"String_Node_Str",fileName));
      return;
    }
    DataConnectionFactory connFactory=session.getDataConnection();
    if (connFactory instanceof IODataConnectionFactory) {
      InetAddress address=((IODataConnectionFactory)connFactory).getInetAddress();
      if (address == null) {
        out.write(new DefaultFtpReply(FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS,"String_Node_Str"));
        return;
      }
    }
    out.write(FtpReplyUtil.translate(session,FtpReply.REPLY_150_FILE_STATUS_OKAY,"String_Node_Str",null));
    boolean failure=false;
    InputStream is=null;
    DataConnection dataConnection;
    try {
      dataConnection=session.getDataConnection().openConnection();
    }
 catch (    Exception e) {
      LOG.debug("String_Node_Str",e);
      out.write(FtpReplyUtil.translate(session,FtpReply.REPLY_425_CANT_OPEN_DATA_CONNECTION,"String_Node_Str",null));
      return;
    }
    try {
      is=openInputStream(connection,session,file,skipLen);
      long transSz=dataConnection.transferToClient(is);
      String userName=session.getUser().getName();
      LOG.info("String_Node_Str" + userName + "String_Node_Str"+ fileName);
      ServerFtpStatistics ftpStat=(ServerFtpStatistics)serverContext.getFtpStatistics();
      if (ftpStat != null) {
        ftpStat.setDownload(connection,file,transSz);
      }
    }
 catch (    SocketException ex) {
      LOG.debug("String_Node_Str",ex);
      failure=true;
      out.write(FtpReplyUtil.translate(session,FtpReply.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED,"String_Node_Str",fileName));
    }
catch (    IOException ex) {
      LOG.debug("String_Node_Str",ex);
      failure=true;
      out.write(FtpReplyUtil.translate(session,FtpReply.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN,"String_Node_Str",fileName));
    }
 finally {
      IoUtils.close(is);
    }
    if (!failure) {
      out.write(FtpReplyUtil.translate(session,FtpReply.REPLY_226_CLOSING_DATA_CONNECTION,"String_Node_Str",fileName));
      try {
        ftpletRet=ftpletContainer.onDownloadEnd(session,request,out);
      }
 catch (      Exception e) {
        LOG.debug("String_Node_Str",e);
        ftpletRet=FtpletEnum.RET_DISCONNECT;
      }
      if (ftpletRet == FtpletEnum.RET_DISCONNECT) {
        serverContext.getConnectionManager().closeConnection(connection);
        return;
      }
    }
  }
  finally {
    session.resetState();
    session.getDataConnection().closeDataConnection();
  }
}