Google
  Web www.spinics.net

trouble w/ synchronized close method in PushbackInputStream

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


Hi,

I'm working with the FTP classes in Apache commons-net 1.4.1.
I am working with classpath 0.96.1 on Buildroot Linux on a Gumstix (ARM cpu).

When my code calls org.apache.commons.net.ftp.FTPClient.disconnect,
the program hangs. Further investigation shows that it gets stuck just
before calling in.close() in java.io.FilterInputStream.
The FilterInputStream.in variable is of the class
org.apache.commons.net.io.FromNetASCIIInputStream, which extends
java.io.PushbackInputStream without redefining the close() method.
The program doesn't enter the PushbackInputStream.close method.

PushbackInputStream.close is synchronized. Apparently there is a
deadlock: if I cut out the "synchronized" keyword, the program runs
to completion. I am guessing that there is a thread sleeping in read()
or something like that; I didn't investigate further.

Incidentally when the same program is run w/ Sun's JRE (java 1.6),
it runs to completion.

At this point I guess I am inclined to plead for trying to reduce
the use of synchronization in PushbackInputStream.
Apparently it is possible to create an implementation of it which
avoids deadlock; Sun's version seems to be evidence of that.

I downloaded the JRE 6 source code and looked at PushbackInputStream;
I can tell you about that if you want.

Robert Dodier


[Linux Kernel]     [Linux Cryptography]     [Fedora]     [Fedora Directory]     [Red Hat Development]

  Powered by Linux