Program: 152230
Project: 152230
Buggy source:
/** 
 * Execute command.
 */
public void execute(final FtpIoSession session,final FtpServerContext context,final FtpRequest request) throws IOException, FtpException {
  boolean success=false;
  ServerFtpStatistics stat=(ServerFtpStatistics)context.getFtpStatistics();
  try {
    session.resetState();
    String password=request.getArgument();
    String userName=session.getUserArgument();
    if (userName == null && session.getUser() == null) {
      session.write(LocalizedFtpReply.translate(session,request,context,FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS,"String_Node_Str",null));
      return;
    }
    if (session.isLoggedIn()) {
      session.write(LocalizedFtpReply.translate(session,request,context,FtpReply.REPLY_202_COMMAND_NOT_IMPLEMENTED,"String_Node_Str",null));
      return;
    }
    boolean anonymous=userName != null && userName.equals("String_Node_Str");
    if (anonymous) {
      int currAnonLogin=stat.getCurrentAnonymousLoginNumber();
      int maxAnonLogin=context.getConnectionConfig().getMaxAnonymousLogins();
      if (currAnonLogin >= maxAnonLogin) {
        session.write(LocalizedFtpReply.translate(session,request,context,FtpReply.REPLY_421_SERVICE_NOT_AVAILABLE_CLOSING_CONTROL_CONNECTION,"String_Node_Str",null));
        return;
      }
    }
    int currLogin=stat.getCurrentLoginNumber();
    int maxLogin=context.getConnectionConfig().getMaxLogins();
    if (maxLogin != 0 && currLogin >= maxLogin) {
      session.write(LocalizedFtpReply.translate(session,request,context,FtpReply.REPLY_421_SERVICE_NOT_AVAILABLE_CLOSING_CONTROL_CONNECTION,"String_Node_Str",null));
      return;
    }
    UserManager userManager=context.getUserManager();
    User authenticatedUser=null;
    try {
      UserMetadata userMetadata=new UserMetadata();
      if (session.getRemoteAddress() instanceof InetSocketAddress) {
        userMetadata.setInetAddress(((InetSocketAddress)session.getRemoteAddress()).getAddress());
      }
      userMetadata.setCertificateChain(session.getClientCertificates());
      Authentication auth;
      if (anonymous) {
        auth=new AnonymousAuthentication(userMetadata);
      }
 else {
        auth=new UsernamePasswordAuthentication(userName,password,userMetadata);
      }
      authenticatedUser=userManager.authenticate(auth);
    }
 catch (    AuthenticationFailedException e) {
      authenticatedUser=null;
      LOG.warn("String_Node_Str");
    }
catch (    Exception e) {
      authenticatedUser=null;
      LOG.warn("String_Node_Str",e);
    }
    User oldUser=session.getUser();
    String oldUserArgument=session.getUserArgument();
    int oldMaxIdleTime=session.getMaxIdleTime();
    if (authenticatedUser != null) {
      session.setUser(authenticatedUser);
      session.setUserArgument(null);
      session.setMaxIdleTime(authenticatedUser.getMaxIdleTime());
      success=true;
    }
 else {
      session.setUser(null);
    }
    if (!success) {
      session.setUser(oldUser);
      session.setUserArgument(oldUserArgument);
      session.setMaxIdleTime(oldMaxIdleTime);
      delayAfterLoginFailure(context.getConnectionConfig().getLoginFailureDelay());
      LOG.warn("String_Node_Str" + userName);
      session.write(LocalizedFtpReply.translate(session,request,context,FtpReply.REPLY_530_NOT_LOGGED_IN,"String_Node_Str",userName));
      stat.setLoginFail(session);
      session.increaseFailedLogins();
      int maxAllowedLoginFailues=context.getConnectionConfig().getMaxLoginFailures();
      if (maxAllowedLoginFailues != 0 && session.getFailedLogins() >= maxAllowedLoginFailues) {
        session.close(false).awaitUninterruptibly(10000);
      }
      return;
    }
    FileSystemFactory fmanager=context.getFileSystemManager();
    FileSystemView fsview=fmanager.createFileSystemView(authenticatedUser);
    session.setLogin(fsview);
    stat.setLogin(session);
    session.write(LocalizedFtpReply.translate(session,request,context,FtpReply.REPLY_230_USER_LOGGED_IN,"String_Node_Str",userName));
    if (anonymous) {
      LOG.info("String_Node_Str" + password);
    }
 else {
      LOG.info("String_Node_Str" + userName);
    }
  }
  finally {
    if (!success) {
      session.reinitialize();
    }
  }
}

Fixed version (ground truth):
/** 
 * Execute command.
 */
public void execute(final FtpIoSession session,final FtpServerContext context,final FtpRequest request) throws IOException, FtpException {
  boolean success=false;
  ServerFtpStatistics stat=(ServerFtpStatistics)context.getFtpStatistics();
  try {
    session.resetState();
    String password=request.getArgument();
    String userName=session.getUserArgument();
    if (userName == null && session.getUser() == null) {
      session.write(LocalizedFtpReply.translate(session,request,context,FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS,"String_Node_Str",null));
      return;
    }
    if (session.isLoggedIn()) {
      session.write(LocalizedFtpReply.translate(session,request,context,FtpReply.REPLY_202_COMMAND_NOT_IMPLEMENTED,"String_Node_Str",null));
      return;
    }
    boolean anonymous=userName != null && userName.equals("String_Node_Str");
    if (anonymous) {
      int currAnonLogin=stat.getCurrentAnonymousLoginNumber();
      int maxAnonLogin=context.getConnectionConfig().getMaxAnonymousLogins();
      if (maxAnonLogin == 0) {
        LOG.debug("String_Node_Str",currAnonLogin);
      }
 else {
        LOG.debug("String_Node_Str",currAnonLogin,maxAnonLogin);
      }
      if (currAnonLogin >= maxAnonLogin) {
        LOG.debug("String_Node_Str");
        session.write(LocalizedFtpReply.translate(session,request,context,FtpReply.REPLY_421_SERVICE_NOT_AVAILABLE_CLOSING_CONTROL_CONNECTION,"String_Node_Str",null));
        return;
      }
    }
    int currLogin=stat.getCurrentLoginNumber();
    int maxLogin=context.getConnectionConfig().getMaxLogins();
    if (maxLogin == 0) {
      LOG.debug("String_Node_Str",currLogin);
    }
 else {
      LOG.debug("String_Node_Str",currLogin,maxLogin);
    }
    if (maxLogin != 0 && currLogin >= maxLogin) {
      LOG.debug("String_Node_Str");
      session.write(LocalizedFtpReply.translate(session,request,context,FtpReply.REPLY_421_SERVICE_NOT_AVAILABLE_CLOSING_CONTROL_CONNECTION,"String_Node_Str",null));
      return;
    }
    UserManager userManager=context.getUserManager();
    User authenticatedUser=null;
    try {
      UserMetadata userMetadata=new UserMetadata();
      if (session.getRemoteAddress() instanceof InetSocketAddress) {
        userMetadata.setInetAddress(((InetSocketAddress)session.getRemoteAddress()).getAddress());
      }
      userMetadata.setCertificateChain(session.getClientCertificates());
      Authentication auth;
      if (anonymous) {
        auth=new AnonymousAuthentication(userMetadata);
      }
 else {
        auth=new UsernamePasswordAuthentication(userName,password,userMetadata);
      }
      authenticatedUser=userManager.authenticate(auth);
    }
 catch (    AuthenticationFailedException e) {
      authenticatedUser=null;
      LOG.warn("String_Node_Str");
    }
catch (    Exception e) {
      authenticatedUser=null;
      LOG.warn("String_Node_Str",e);
    }
    User oldUser=session.getUser();
    String oldUserArgument=session.getUserArgument();
    int oldMaxIdleTime=session.getMaxIdleTime();
    if (authenticatedUser != null) {
      session.setUser(authenticatedUser);
      session.setUserArgument(null);
      session.setMaxIdleTime(authenticatedUser.getMaxIdleTime());
      success=true;
    }
 else {
      session.setUser(null);
    }
    if (!success) {
      session.setUser(oldUser);
      session.setUserArgument(oldUserArgument);
      session.setMaxIdleTime(oldMaxIdleTime);
      delayAfterLoginFailure(context.getConnectionConfig().getLoginFailureDelay());
      LOG.warn("String_Node_Str" + userName);
      session.write(LocalizedFtpReply.translate(session,request,context,FtpReply.REPLY_530_NOT_LOGGED_IN,"String_Node_Str",userName));
      stat.setLoginFail(session);
      session.increaseFailedLogins();
      int maxAllowedLoginFailues=context.getConnectionConfig().getMaxLoginFailures();
      if (maxAllowedLoginFailues != 0 && session.getFailedLogins() >= maxAllowedLoginFailues) {
        LOG.warn("String_Node_Str");
        session.close(false).awaitUninterruptibly(10000);
      }
      return;
    }
    FileSystemFactory fmanager=context.getFileSystemManager();
    FileSystemView fsview=fmanager.createFileSystemView(authenticatedUser);
    session.setLogin(fsview);
    stat.setLogin(session);
    session.write(LocalizedFtpReply.translate(session,request,context,FtpReply.REPLY_230_USER_LOGGED_IN,"String_Node_Str",userName));
    if (anonymous) {
      LOG.info("String_Node_Str" + password);
    }
 else {
      LOG.info("String_Node_Str" + userName);
    }
  }
  finally {
    if (!success) {
      session.reinitialize();
    }
  }
}