Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

MimeMessage.writeTo hangs on PipedInputStream.awaitSpace()

843830Jul 9 2006 — edited Jul 17 2006
Hi all,

I have a multi-threaded app which (amongst other things) creates mail files and writes them to disk. When this app is under heavy load, I get several threads "left behind" which appear to be stuck on the call to awaitSpace() within the PipedInputStream class.

In debug, I notice that this method just loops around forever waiting for input. The problem is that I'm not controlling this. I'm just calling the writeTo(OutputStream) method of the MimeMessage class in JavaMail.

Goes something like this...
FileOutputStream fout = null;

try {

	fout = new FileOutputStream("somefile.txt");

	// Just a normal MimeMessage class initialised elsewhere
	message.writeTo(out);

	fout.flush();

}
finally {
	if (fout != null) {
		fout.close();
	}
}
This obviously works fine, but under heavy load the call to message.writeTo(out); blocks forever.

Not sure if it's a problem with the MimeMessage class or the PipedInputStream class (or my code?).

Anyone seen this behaviour before?

I'm using JDK 1.5.0_04
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 14 2006
Added on Jul 9 2006
6 comments
746 views