FtpServer
  1. FtpServer
  2. FTPSERVER-290

DefaultFtpStatistics throws NullPointerException when account login repeatdly

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.0.0
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None
    • Environment:
      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 (flag)

      { 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) {
      }
      }
      }

      }

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

        Activity

        Hide
        Niklas Gustavsson added a comment -

        I've failed to reproduce this on my Ubuntu laptop using the attached test case. There are some lines missing in your test case above, does my example do the same thing yours do? Also, could you provide the code as to how the server is started in your case?

        Also, would you be able to check whatever path the code takes in org.apache.ftpserver.impl.FtpIoSession.getRemoteAddress() when this bug happens to you? For example by adding logging statements. Please let me know if I can be of any assistance in this!

        Show
        Niklas Gustavsson added a comment - I've failed to reproduce this on my Ubuntu laptop using the attached test case. There are some lines missing in your test case above, does my example do the same thing yours do? Also, could you provide the code as to how the server is started in your case? Also, would you be able to check whatever path the code takes in org.apache.ftpserver.impl.FtpIoSession.getRemoteAddress() when this bug happens to you? For example by adding logging statements. Please let me know if I can be of any assistance in this!
        Hide
        Ulysses Lee added a comment -

        Right your test code is do the same thing as mine. And I'am using ftp server in embed way,
        the structure is like that: I has a servlet extends HttpServlet who configured in web.xml as a servlet, and I has a server-control class like attachment.

        I use Resin 3.0 as container to run this.

        Show
        Ulysses Lee added a comment - Right your test code is do the same thing as mine. And I'am using ftp server in embed way, the structure is like that: I has a servlet extends HttpServlet who configured in web.xml as a servlet, and I has a server-control class like attachment. I use Resin 3.0 as container to run this.
        Hide
        Ulysses Lee added a comment -

        The disappointing thing is whatever I try many time today, it could not reproduce the Exception at all... I would like to make a notice at this bug, try to reproduce it ,

        My JVM is JDK1.6u13

        Show
        Ulysses Lee added a comment - The disappointing thing is whatever I try many time today, it could not reproduce the Exception at all... I would like to make a notice at this bug, try to reproduce it , My JVM is JDK1.6u13

          People

          • Assignee:
            Unassigned
            Reporter:
            Ulysses Lee
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Development