[kaffe] org.apache.commons.net.ftp.FTPClient: disconnect() hangs

Ito Kazumitsu kaz at maczuka.gcd.org
Sun Oct 10 15:29:03 PDT 2004


Hi,

My next target application to be run with Kaffe is openadaptor
(http://www.openadaptor.org/).

While testing openadaptor, I found a case where the package
org.apache.commons.net.ftp from Jakarta Commons http://jakarta.apache.org/
does not work properly.

The attached program, which ends normally with Sun's JDK,
will not stop with kaffe.  Does it go into a deadlock?

bash-2.05b$ cat TestApacheFTP.java 
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPReply;
public class TestApacheFTP
{
	private FTPClient _ftpClient;
	public static void main(String[] args) throws Exception
	{
		TestApacheFTP ftp = new TestApacheFTP();
		ftp.connect(args[0], 21);
		ftp.login(args[1], args[2]);
		ftp.close();
	}
	public void connect(String hostName, int port) throws Exception
	{
		debug("Connecting to " + hostName + " on port " + port);
		_ftpClient = new FTPClient();
		_ftpClient.connect(hostName, port);
		if (!FTPReply.isPositiveCompletion(_ftpClient.getReplyCode()))
		{
			_ftpClient.disconnect();
			throw new Exception("Failed to connect");
		}
		debug("ApacheFTP object initialised and connected to " + hostName);
	}
	public void login(String userName, String password) throws Exception
	{
		debug("Logging in " + userName);
		if (!_ftpClient.login(userName, password))
		{
			_ftpClient.disconnect();
			throw new Exception(userName + " Failed to login");
		}
		debug(userName + " logged in");
	}
	public void close() throws Exception
	{
		debug("trying to close FTP Connection");
		if (_ftpClient.isConnected())
		{
			debug("disconnecting FTP Connection");
			_ftpClient.disconnect();
			debug("FTP Connection closed");
		}
	}
	private static void debug(String s)
	{
		System.err.println("DEBUG: " + s);
		System.err.flush();
	}
}
bash-2.05b$ kaffe TestApacheFTP localhost kaz ilvmke413
DEBUG: Connecting to localhost on port 21
DEBUG: ApacheFTP object initialised and connected to localhost
DEBUG: Logging in kaz
DEBUG: kaz logged in
DEBUG: trying to close FTP Connection
DEBUG: disconnecting FTP Connection
^C




More information about the kaffe mailing list