- This bug only happens when running under JDK1.3.x or lower.
(when running under JDK1.4.x or higher, this bug does not happen)
- Create and configure an FTP server. Make sure it runs OK.
- Create a program and run it under JDK1.3.x or lower:
=== Test Program ===================================
...
...
// Connect to the above FTP server and login
// Check that everything went fine.
...
while (true)
{
try {
FTPFile[] files = ftpClient.listFiles("*");
showFiles(files);
}
catch (FTPConnectionClosedException fcce) {
// Oops.. the FTP server has been disconnected.
System.out.println("Disconnected from FTP Server. Ending prog.");
break; // while(true)
}
Thread.sleep(3000);
}
... // close/disconnect and clean-up.
...
====================================================
- Run the above program. The ftpClient.listFiles(...) works OK.
- At some point, stop the FTP server.
=== Expected result: ===============================
Program ends normally with message "Disconnected from FTP Server. Ending prog."
====================================================
=== Actual result: =================================
Pogram throws java.lang.NoSuchMethodError.
====================================================
=== Stacktrace: ====================================
java.lang.NoSuchMethodError
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:442)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:484)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:533)
at org.apache.commons.net.ftp.FTP.pasv(FTP.java:833)
at org.apache.commons.net.ftp.FTPClient.openDataConnection
(FTPClient.java:493)
at org.apache.commons.net.ftp.FTPClient.initiateListParsing
(FTPClient.java:2356)
at org.apache.commons.net.ftp.FTPClient.initiateListParsing
(FTPClient.java:2330)
at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2072)
at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2123)
====================================================
=== Probable cause: ================================
The FTP.sendCommand(...) method, on line 442 is as follows:
if (!isConnected() || socket == null || !socket.isConnected())
The 'socket' variable is of type 'java.net.Socket'.
Under JKD1.3, the 'java.net.Socket' class does NOT implement 'isConnected()'.
====================================================
Why this bug is "P1 & critical": If the FTP Server closed the connection (e.g.
due to a time-out), our code catches the FTPConnectionClosedException exception
and tries to reconnect to the server. If this exception is not thrown, but the
NoSuchMethodError is thrown instead, our code fails.
PS: It is hard to find information about which JDK-versions support the
Commons/Net component. This page (http://jakarta.apache.org/commons/net/changes-
report.html#1_3_0), indicates that the component should run correctly at least
under JDK1.3.x.
COM-1663 (the patch from "2004-12-30 08:57" never made it into version
1.3.Final...?).