Issue Details (XML | Word | Printable)

Key: NET-145
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Norbert Seekircher
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Commons Net

Deadlock in TelnetInputStream

Created: 28/Nov/06 01:40 PM   Updated: 03/Jan/07 04:16 PM
Return to search
Component/s: None
Affects Version/s: 1.4
Fix Version/s: 2.0

Time Tracking:
Not Specified

Environment: Heavy mutlithreaded environment using Jakarta VFS (which uses Commons Net) for ftp file transfers
Issue Links:
Reference
 

Resolution Date: 20/Dec/06 10:53 AM


 Description  « Hide
"Sometimes" single threads of our application (each thread transfering data from ftp servers) get locked forever. When monitoring our tool with JConsole, I can see that such a thread usually hangs at org.apache.commons.net.telnet.TelnetInputStream, line 339.

This line contains the statement
__queue.wait();

Unfortunately I haven't found a way to reproduce this issue, it just happens about once a day (while running 24 hours and transfering about 50000 files).

As a quick and dirty workaround: What do you think about replacing this line with something like
long startTime = System.currentTimeMillis();
__queue.wait(60000);
if ((System.currentTimeMillis() - startTime) > 55000) {
throw new InterruptedException("Unknown strange and nasty blocker detected");
}

So at least it would not just block the thread.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Rory Winston added a comment - 28/Nov/06 04:19 PM
Norbert

This should be fixed in the snapshot of commons-net-2.0, although this requires JDK 1.5+. If you are in a position to test this, it would be great if you can verify if it works or not:

http://people.apache.org/~rwinston/commons-net-2.0/commons-net-ftp-2.0.0-SNAPSHOT.jar


Norbert Seekircher added a comment - 01/Dec/06 01:58 PM
Thanks Rory,

we will test this build and report back


Rory Winston added a comment - 20/Dec/06 10:53 AM
This issue is fixed in 2.0.

Marco Campelo added a comment - 03/Jan/07 04:05 PM
This deadlock happens when you lost the connection with the FTP server and tries to send a logout () command.

Find below the thead dump from a Solaris box:

Full thread dump Java HotSpot(TM) Client VM (1.4.2_08-b03 mixed mode):

"Thread-0" daemon prio=6 tid=0x001cbf18 nid=0x9 runnable [f9a7f000..f9a7fc30]
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
at java.io.BufferedInputStream.read(BufferedInputStream.java:201)

  • locked <0xf1845a20> (a java.io.BufferedInputStream)
    at java.io.FilterInputStream.read(FilterInputStream.java:66)
    at java.io.PushbackInputStream.read(PushbackInputStream.java:120)
    at org.apache.commons.net.io.FromNetASCIIInputStream.__read(FromNetASCIIInputStream.java:75)
    at org.apache.commons.net.io.FromNetASCIIInputStream.read(FromNetASCIIInputStream.java:170)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
  • locked <0xf1846988> (a org.apache.commons.net.telnet.TelnetInputStream)
    at org.apache.commons.net.telnet.TelnetInputStream.__read(TelnetInputStream.java:114)
    at org.apache.commons.net.telnet.TelnetInputStream.run(TelnetInputStream.java:535)
    at java.lang.Thread.run(Thread.java:534)

"Signal Dispatcher" daemon prio=10 tid=0x000cddc0 nid=0x6 waiting on condition [0..0]

"Finalizer" daemon prio=8 tid=0x000c7d68 nid=0x4 in Object.wait() [fc77f000..fc77fc30]
at java.lang.Object.wait(Native Method)

  • waiting on <0xf1f437a8> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:111)
  • locked <0xf1f437a8> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:127)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

"Reference Handler" daemon prio=10 tid=0x000c72e8 nid=0x3 in Object.wait() [fe27f000..fe27fc30]
at java.lang.Object.wait(Native Method)

  • waiting on <0xf1f43810> (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:429)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:115)
  • locked <0xf1f43810> (a java.lang.ref.Reference$Lock)

"main" prio=5 tid=0x000356b8 nid=0x1 in Object.wait() [ffbfe000..ffbff164]
at java.lang.Object.wait(Native Method)

  • waiting on <0xf18475f8> (a [I)
    at java.lang.Object.wait(Object.java:429)
    at org.apache.commons.net.telnet.TelnetInputStream.read(TelnetInputStream.java:339)
  • locked <0xf18475f8> (a [I)
    at org.apache.commons.net.telnet.TelnetInputStream.read(TelnetInputStream.java:466)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:220)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:277)
  • locked <0xf1849700> (a java.io.BufferedInputStream)
    at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:408)
    at sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:450)
    at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:182)
  • locked <0xf184a0c0> (a java.io.InputStreamReader)
    at java.io.InputStreamReader.read(InputStreamReader.java:167)
    at java.io.BufferedReader.fill(BufferedReader.java:136)
    at java.io.BufferedReader.readLine(BufferedReader.java:299)
  • locked <0xf184a0c0> (a java.io.InputStreamReader)
    at java.io.BufferedReader.readLine(BufferedReader.java:362)
    at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:264)
    at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:460)
    at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:520)
    at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:569)
    at org.apache.commons.net.ftp.FTP.quit(FTP.java:781)
    at org.apache.commons.net.ftp.FTPClient.logout(FTPClient.java:706)
    at com.nokia.ci.nwg.util.ftp.FTPHandler.disconnect(FTPHandler.java:318)
    at com.nokia.ci.nwg.CDRTransmitter.doPerformControl(CDRTransmitter.java:71)
    at com.nokia.ci.nwg.CDRProcessor.doProccessCDRs(CDRProcessor.java:59)
    at com.nokia.ci.nwg.CDRProcessor.main(CDRProcessor.java:85)

"VM Thread" prio=5 tid=0x000c64a0 nid=0x2 runnable

"VM Periodic Task Thread" prio=10 tid=0x000d0c20 nid=0x8 waiting on condition
"Suspend Checker Thread" prio=10 tid=0x000cd488 nid=0x5 runnable