issues@javamail.java.net

[Bug 3155] New: ArrayIndexOutOfBoundsException at com.sun.mail.imap.MessageCache.getMessage(MessageCache.java:117)

From: <bugzilla-daemon_at_kenai.com>
Date: Mon, 27 Sep 2010 16:07:39 +0000 (GMT)

http://kenai.com/bugzilla/show_bug.cgi?id=3155

           Summary: ArrayIndexOutOfBoundsException at
                    com.sun.mail.imap.MessageCache.getMessage(MessageCache
                    .java:117)
           Product: javamail
           Version: 1
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P5
         Component: source
        AssignedTo: shannon_at_kenai.com
        ReportedBy: Ronald_Zuniga_at_kenai.com
                CC: issues_at_javamail.kenai.com


Hi!

We're getting this exception when reading an attachment from a part using this
code:

1. Message message;
2. Multipart multipart = (Multipart) message.getContent();
3. Part part = multipart.getBodyPart(index);
4. IOUtils.copyLarge(part.getInputStream(), contentsOutputStream);

Exception is thrown in the line 4. Here we're reading the contents of the
attachment to an outputStream that is a ByteArrayOutputStream.

I didn't find this as a bug in the bug database.

Any help with this will be very appreciated as It is affecting a service in
production that we have.

Here is the stack trace, we're using Microsoft's mail server with IMAP to
retrieve mail from a cron job.

java.lang.ArrayIndexOutOfBoundsException: message number out of bounds
    at com.sun.mail.imap.MessageCache.getMessage(MessageCache.java:117)
    at com.sun.mail.imap.MessageCache.getMessageBySeqnum(MessageCache.java:147)
    at com.sun.mail.imap.IMAPFolder.getMessageBySeqNumber(IMAPFolder.java:2735)
    at com.sun.mail.imap.IMAPFolder.handleResponse(IMAPFolder.java:2412)
    at com.sun.mail.iap.Protocol.notifyResponseHandlers(Protocol.java:212)
    at
com.sun.mail.imap.protocol.IMAPProtocol.fetchBody(IMAPProtocol.java:1222)
    at
com.sun.mail.imap.protocol.IMAPProtocol.fetchBody(IMAPProtocol.java:1209)
    at com.sun.mail.imap.IMAPInputStream.fill(IMAPInputStream.java:144)
    at com.sun.mail.imap.IMAPInputStream.read(IMAPInputStream.java:204)
    at com.sun.mail.imap.IMAPInputStream.read(IMAPInputStream.java:230)
    at
com.sun.mail.util.BASE64DecoderStream.getByte(BASE64DecoderStream.java:354)
    at
com.sun.mail.util.BASE64DecoderStream.decode(BASE64DecoderStream.java:245)
    at com.sun.mail.util.BASE64DecoderStream.read(BASE64DecoderStream.java:140)
    at java.io.FilterInputStream.read(FilterInputStream.java:90)
    at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1025)
    at
com.odc.salesforceservice.messaging.inbounddocument.mail.EmailParser.addAttachments(EmailParser.java:130)

-- 
Configure bugmail: http://kenai.com/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.