You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Niklas Gustavsson (JIRA)" <ji...@apache.org> on 2009/04/14 12:13:15 UTC

[jira] Commented: (FTPSERVER-290) DefaultFtpStatistics throws NullPointerException when account login repeatdly

    [ https://issues.apache.org/jira/browse/FTPSERVER-290?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12698724#action_12698724 ] 

Niklas Gustavsson commented on FTPSERVER-290:
---------------------------------------------

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!

> DefaultFtpStatistics throws NullPointerException when account login repeatdly
> -----------------------------------------------------------------------------
>
>                 Key: FTPSERVER-290
>                 URL: https://issues.apache.org/jira/browse/FTPSERVER-290
>             Project: FtpServer
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 1.0.0
>         Environment: Linux RedHat EL 2.6.9-42.ELsmp
>            Reporter: Ulysses Lee
>
>  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) {
> 			}
> 		}
> 	}
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.