If myFTPClient.setReaderThread(false) and many ftp clients are instanciated
over time, the VM gets out of memory errors. The problem is that the underlying
TelnetClient's TelnetInputStream creates a new thread that it never uses (never
starts, or joins). The VM is unable to garbage collect these zombie threads.
This problem is paticularly notable given that several users have observed
hangs doing continual ftp unless setReaderThread(false). This observed on hpux
jdk 1.3 <todo lookup specific version>
Here's a patch:
cvs server: Diffing src/java/org/apache/commons/net/telnet
Index: src/java/org/apache/commons/net/telnet/TelnetClient.java
===================================================================
RCS file: /home/cvspublic/jakarta-
commons/net/src/java/org/apache/commons/net/telnet/TelnetClient.java,v
retrieving revision 1.12
diff -r1.12 TelnetClient.java
100,101c100
<
< tmp = new TelnetInputStream(input, this);
—
> tmp = new TelnetInputStream(input, this, readerThread);
Index: src/java/org/apache/commons/net/telnet/TelnetInputStream.java
===================================================================
RCS file: /home/cvspublic/jakarta-
commons/net/src/java/org/apache/commons/net/telnet/TelnetInputStream.java,v
retrieving revision 1.11
diff -r1.11 TelnetInputStream.java
56c56
< TelnetInputStream(InputStream input, TelnetClient client)
—
> TelnetInputStream(InputStream input, TelnetClient client, boolean
readerThread)
72c72,74
< __thread = new Thread(this);
—
> if (readerThread) {
> __thread = new Thread(this);
> }
76a79
> if (__thread==null) { return; }
498c501
< if (__thread.isAlive())
—
> if (__thread!=null && __thread.isAlive())
Java(TM) 2 Runtime Environment, Standard Edition (build jinteg:11/28/00-11:08)
HotSpot VM (build 1.0.1fcs jinteg:11/28/00-13:54 PA2.0, mixed mode)