commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Beyer (JIRA)" <>
Subject [jira] Commented: (NET-168) NullPointerException in TelnetClient.disconnect() while being connected
Date Tue, 28 Aug 2007 03:55:30 GMT


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:
>             Project: Commons Net
>          Issue Type: Bug
>    Affects Versions: 1.4
>         Environment: Debian GNU/Linux, FedoraCore, RedHat
>            Reporter: Kamil
> java.lang.NullPointerException
> 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.

View raw message