[
https://issues.apache.org/jira/browse/NET-168?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12522951
]
Kamil commented on NET-168:
---------------------------
yes, i do.
Here is class which is using FTPClient:
public class FtpTester{
private FTPClient ftpCon=null;
public void testHandler(String host,long timeout,Authentication auth) {
long startTime = 0;
long totalTime = 0;
long startDownloadTime = 0;
long totalDownloadTime = 0;
String res = "";
int resp=0;
String exception=null;
try {
ftpCon=new FTPClient();
startTime = System.currentTimeMillis();
ftpCon.setDefaultTimeout((int) timeout);
ftpCon.connect(host,21);
String user=null;
String pass=null;
if(auth!=null){
user=auth.getUsername();
pass=auth.getPassword();
}
if(user!=null && pass!=null){
ftpCon.user(user);
ftpCon.pass(pass);
}
else{
ftpCon.user("anonymous");
ftpCon.pass("");
}
startDownloadTime = System.currentTimeMillis();
res=ftpCon.getReplyString();
resp= ftpCon.getReplyCode();
totalDownloadTime =
System.currentTimeMillis()-startDownloadTime;
totalTime = System.currentTimeMillis()-startTime;
}catch (Exception e) {
e.printStackTrace();
exception=e.getMessage();
}finally{
try {
if(ftpCon!=null && ftpCon.isConnected()){
//ftpCon.logout();
ftpCon.disconnect(); //HERE occured an
Exception
}
} catch (IOException e) {
}
}
}
public void interrupt() {//used in different thread if connection hangs
for a long time
try {
if(ftpCon!=null&& ftpCon.isConnected()){
ftpCon.disconnect();
}
} catch (IOException e) {
}
}
}
It's not so common - it happens once a week maybe, but it's strange.
While this exception happens - as you see - i'm disconnecting FTPClient.
It's a server, so in other threads i have Http connections running, but it
shouldn't matter. Server connects to ftp do some connection tests. It's running
all the time.
I Hope that it would help.
Regards
---- Wiadomość Oryginalna ----
Od: "Nathan Beyer (JIRA)" <[EMAIL PROTECTED]>
Do: [EMAIL PROTECTED]
Data: 27 sierpnia 2007 3:21
Temat: [jira] Commented: (NET-168) NullPointerException in
TelnetClient.disconnect() while being connected
> NullPointerException in TelnetClient.disconnect() while being connected
> -----------------------------------------------------------------------
>
> Key: NET-168
> URL: https://issues.apache.org/jira/browse/NET-168
> Project: Commons Net
> Issue Type: Bug
> Affects Versions: 1.4
> Environment: Debian GNU/Linux, FedoraCore, RedHat
> Reporter: Kamil
>
> java.lang.NullPointerException
> org.apache.commons.net.telnet.TelnetClient.disconnect(TelnetClient.java:125)
> org.apache.commons.net.ftp.FTP.disconnect(FTP.java:397)
> org.apache.commons.net.ftp.FTPClient.disconnect(FTPClient.java:590)
> This exception occurs when trying to invoke myFTPClient.disconnect() method,
> when ftpclient hangs for a long time and dont want to connect...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.