Search code examples
javaemailjakarta-eejakarta-mailimap

Exception while Imap Fetch


I have written a bulk fetch IMAP command as suggested in this post.

It's working perfectly and fast when I am running it as JUnit or independently as a jar utility.

The moment I deploy it on JBoss, and start running as a quartz scheduler, the exception below starts to occur. I checked Dynatrace and I don't see any spike in CPU or memory.

Could someone please suggest me what parameters can be checked in JBoss which could be causing any limitation on buffer size or IMAP connection time. I checked if there is any conflicting Java mail jar but no luck.

java.lang.IndexOutOfBoundsException
    at java.io.BufferedInputStream.read(BufferedInputStream.java:327)
    at com.sun.mail.iap.ResponseInputStream.readResponse(ResponseInputStream.java:154)
    at com.sun.mail.iap.Response.<init>(Response.java:95)
    at com.sun.mail.imap.protocol.IMAPResponse.<init>(IMAPResponse.java:60)
    at com.sun.mail.imap.protocol.IMAPResponse.readResponse(IMAPResponse.java:134)
    at com.sun.mail.imap.protocol.IMAPProtocol.readResponse(IMAPProtocol.java:270)
    at com.sun.mail.iap.Protocol.command(Protocol.java:313)
    at com.macys.notification.handlers.impl.BCCArchiveHandler$CustomProtocolCommand.doCommand(BCCArchiveHandler.java:321)
    at com.sun.mail.imap.IMAPFolder.doProtocolCommand(IMAPFolder.java:2721)
    at com.sun.mail.imap.IMAPFolder.doCommand(IMAPFolder.java:2671)

Solution

  • I finally got the solution. On jboss server, ssl debug logs were turned on. Once I removed -Djavax.net.debug=ssl,handshake -Djavax.net.debug=all, it got fixed.