You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Stephan Schiessling <s...@rapi.com> on 2002/05/03 23:10:50 UTC

Bug in MimeMessageSource results in countless open streams

After my mailbox was filled with about 900 emails, I could not get
these emails by pop3.

The reason: Could not open file, because
too many open file descriptors were already opened.
For each email in the users mailbox, two streams were opened
(but not closed) (The streams werde opened for
determining the length of the email).

To fix this problem:

In the source file
src/java/org/apache/james/core/MimeMessageSource.java
replace the method

public long getMessageSize() throws IOException{
.....
}

by

public long getMessageSize() throws IOException {
         int size = 0;
         InputStream in = null;
         try {
             in = getInputStream();
             int read = 0;
             byte[] data = new byte[1024];
             while ((read = in.read(data)) > 0) {
                 size += read;
             }
         } finally {
             if (in != null) in.close();
         }
         return size;
     }

Here the InputStream "in" will be closed. This should fix the problem.

Bye,

Stephan Schiessling


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>