Uploaded image for project: 'FtpServer'
  1. FtpServer
  2. FTPSERVER-290

DefaultFtpStatistics throws NullPointerException when account login repeatdly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.0.0
    • None
    • Core
    • None
    • Linux RedHat EL 2.6.9-42.ELsmp

    Description

      When I write a Testcase to make a proformance test for Apache ftp server,
      and I only use ONE ftp account in many threads to upload different files, then after about 10 users loged in,
      it throws exception:

      [2009-04-14 09:30:52,973] [WARN ] DefaultFtpHandler [t001@bbapp.net] [125.88.130.8] - RequestHandler.service()
      java.lang.NullPointerException
      at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:768)
      at org.apache.ftpserver.impl.DefaultFtpStatistics$UserLogins.loginsFromInetAddress(DefaultFtpStatistics.java:90)
      at org.apache.ftpserver.impl.DefaultFtpStatistics.getCurrentUserLoginNumber(DefaultFtpStatistics.java:259)
      at org.apache.ftpserver.command.impl.USER.execute(USER.java:152)
      at org.apache.ftpserver.impl.DefaultFtpHandler.messageReceived(DefaultFtpHandler.java:169)
      at org.apache.ftpserver.listener.nio.FtpHandlerAdapter.messageReceived(FtpHandlerAdapter.java:65)

      most likey a thread lock problem?

      My test case used Apache NET lib with FTP, it like:

      import java.io.BufferedInputStream;
      import java.io.File;
      import java.io.FileInputStream;
      import java.io.IOException;
      import java.io.InputStream;

      import org.apache.commons.net.ftp.FTP;
      import org.apache.commons.net.ftp.FTPClient;
      import org.apache.commons.net.ftp.FTPReply;

      public static void main(String[] args) {
      starttime = System.currentTimeMillis();
      final File f = new File("F:/WorkSpace/Hermes/Hermes.jar");

      for (int i = 0; i < 300; i++) {
      final int j = i;
      new Thread() {
      public void run()

      { testUpload("user", "pass", f); }

      }.start();
      }
      }

      public static void testUpload(String username, String password, File localFile) {

      FTPClient ftp = new FTPClient();
      try {
      ftp.connect(server, port);
      System.out.println("Connected to " + server + ".");
      ftp.login(username, password);

      int reply = ftp.getReplyCode();

      if (!FTPReply.isPositiveCompletion(reply))

      { ftp.disconnect(); System.err.println("FTP server refused connection."); System.exit(1); }

      ftp.setFileType(FTP.BINARY_FILE_TYPE);
      ftp.enterLocalActiveMode();
      ftp.setFileTransferMode(FTP.STREAM_TRANSFER_MODE);
      InputStream input = new FileInputStream(localFile);
      BufferedInputStream bin = new BufferedInputStream(input);

      boolean flag = ftp.storeFile(localFile.getName(), bin);

      if

      { System.out.println("success! cost:<" + (System.currentTimeMillis() - starttime) + " ms>"); }

      else

      { System.out.println("fail! cost:<" + (System.currentTimeMillis() - starttime) + " ms>"); }

      ftp.logout();
      } catch (IOException e)

      { e.printStackTrace(); }

      finally {
      if (ftp.isConnected()) {
      try

      { ftp.disconnect(); }

      catch (IOException ioe) {
      }
      }
      }

      }

      Attachments

        1. config.xml
          0.8 kB
          Ulysses Lee
        2. NetDiskFtpServlet.java
          0.8 kB
          Ulysses Lee
        3. NetDiskFtpServer.java
          3 kB
          Ulysses Lee
        4. NetDiskFtpConfig.java
          5 kB
          Ulysses Lee
        5. Test.java
          2 kB
          Niklas Therning

        Activity

          People

            Unassigned Unassigned
            ukinglli Ulysses Lee
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: