I just found out the culprit, it is not James code. It is
javax.mail.MimeMessage

Exactly:
    /**
     * Byte array that holds the bytes of this Message's content.
     */
    protected byte[] content;

.......

        content = ASCIIUtility.getBytes(is);
in:

   protected void parse(InputStream is) throws MessagingException {

    if (!(is instanceof ByteArrayInputStream) &&
        !(is instanceof BufferedInputStream) &&
        !(is instanceof SharedInputStream))
        is = new BufferedInputStream(is);

    headers = createInternetHeaders(is);

    if (is instanceof SharedInputStream) {
        SharedInputStream sis = (SharedInputStream)is;
        contentStream = sis.newStream(sis.getPosition(), -1);
    } else {
        try {
        content = ASCIIUtility.getBytes(is);
        } catch (IOException ioex) {
        throw new MessagingException("IOException", ioex);
        }
    }
---------------------------------------------------------------

The ASCIIUtility.getBytes(s):

   public static byte[] getBytes(InputStream is) throws IOException {

    int len;
    int size = 1024;
    byte [] buf;


    if (is instanceof ByteArrayInputStream) {
        size = is.available();
        buf = new byte[size];
        len = is.read(buf, 0, size);
    }
    else {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        buf = new byte[size];
        while ((len = is.read(buf, 0, size)) != -1)
        bos.write(buf, 0, len);
        buf = bos.toByteArray();
    }
    return buf;
    }
}
-------------------------------------------

I traced that the

while ((len = is.read(buf, 0, size)) != -1)
        bos.write(buf, 0, len);

causes the exception.
-----------------------------------


With big attachment, this will crash. Any idea to avoid this?

On 12/30/05, Edward Tan <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> James suddenly crash when I receive > 30MB attachment. I didn't check the
> threshold of message size that causes this. I just happened to send 34 MB
> attachment through Thunderbird to James. The problem is caused by my mailet
> which tries to get the flag:
>
>
> in my my mailet:
>
>                 message = mail.getMessage();
>
> .....
>
>
>                 // FLAGS
> ---> (exception when calling this:)              Flags flags =
> message.getFlags();
>
>
> The exception is caught in org.apache.james.transport.JamesSpoolManager
>
> line 233:
>             } catch (Throwable e) {
>                 // This is a strange error situation that shouldn't
> ordinarily
>                 // happen
>                 StringBuffer exceptionBuffer =
>                     new StringBuffer(64)
>                             .append("Exception in processor <")
>                             .append(processorName)
>                             .append(">");
>                 getLogger().error(exceptionBuffer.toString(), e);
>                 if (processorName.equals(Mail.ERROR)) {
>                     // We got an error on the error processor...
>                     // kill the message
>                     mail.setState(Mail.GHOST);
>                     mail.setErrorMessage(e.getMessage());
>
>
> Has anyone experienced before?
>
> Any limit on message size?
>
> Regards,
> Edward
>

Reply via email to