[
https://issues.apache.org/jira/browse/NET-168?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12523150
]
Nathan Beyer commented on NET-168:
----------------------------------
Based on that code snippet, I would say that you have a concurrency issue. It's
even presenting as a concurrency issue - it happens rarely and sporadically.
FTPClient is not thread safe, you can't invoke methods on it concurrently,
which your code appears to be doing. The 'testHandler' and 'interrupt' method
are being invoked on two different threads, correct? If you want to maintain
the FTPClient as a instance variable, you'll have to synchronize access to it;
only one thread can be interacting with it at a time. Note, access to the field
itself must be synchronized as well, but you can generally do this with the
same lock. Are you reusing instances of FTPClient amongst different threads?
To get a better understanding of what's happening, I would suggest putting some
tracing in this class to see when, how many times and on what thread the
methods are getting invoked. I think you'll be surprised as to what you see.
> 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.