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!

Null pointer exeception in BODYSTRUCTURE.parseParameters. Is it a bug ?

216944Nov 6 2012 — edited Dec 31 2013
I am trying to fetch messages from an IMAP account and I get a null pointer exception in BODYSTRUCTURE.parseParameters method.

Looking the parseParameters code, I find this line
list.set(null, "DONE"); // XXX - hack

The problem is that the set method tries to call *.toLowerCase()* to the null value !!!

The response it is trying to parse is this:

* 1 FETCH (BODYSTRUCTURE (("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 55 4 NIL NIL NIL NIL)(("TEXT" "HTML" ("CHARSET" "us-ascii") NIL NIL "7BIT" 410 10 NIL NIL NIL NIL)("IMAGE" "JPEG" ("NAME" "image.jpg") "<53498286-6B3E-4AC8-8CA0-481152C80968@xxxx.it>" NIL "BASE64" 536628 NIL ("inline" ("FILENAME" "image.jpg")) NIL NIL) "RELATED" ("TYPE" "text/html" "BOUNDARY" "Apple-Mail=_56FA3EC6-FB02-4882-A1C5-487652E3B4E5") NIL NIL NIL) "ALTERNATIVE" ("BOUNDARY" "Apple-Mail=_CB164992-2501-4351-94D1-61CE7C8D90DC") NIL NIL NIL))

and, enabling the debug, I get those messages:

DEBUG IMAP: parsing BODYSTRUCTURE
DEBUG IMAP: msgno 1
DEBUG IMAP: parsing multipart
DEBUG IMAP: parsing BODYSTRUCTURE
DEBUG IMAP: msgno 1
DEBUG IMAP: single part
DEBUG IMAP: type TEXT
DEBUG IMAP: subtype PLAIN
DEBUG IMAP: parameter name CHARSET
DEBUG IMAP: parameter value us-ascii

and then the NullPointerException

Exception in thread "main" java.lang.NullPointerException
at javax.mail.internet.ParameterList.set(ParameterList.java:165)
at com.sun.mail.imap.protocol.BODYSTRUCTURE.parseParameters(BODYSTRUCTURE.java:404)
at com.sun.mail.imap.protocol.BODYSTRUCTURE.<init>(BODYSTRUCTURE.java:224)
at com.sun.mail.imap.protocol.BODYSTRUCTURE.<init>(BODYSTRUCTURE.java:109)
at com.sun.mail.imap.protocol.FetchResponse.parse(FetchResponse.java:158)
at com.sun.mail.imap.protocol.FetchResponse.<init>(FetchResponse.java:67)
at com.sun.mail.imap.protocol.IMAPResponse.readResponse(IMAPResponse.java:136)
at com.sun.mail.imap.protocol.IMAPProtocol.readResponse(IMAPProtocol.java:270)
at com.sun.mail.iap.Protocol.command(Protocol.java:313)
at com.sun.mail.imap.protocol.IMAPProtocol.fetch(IMAPProtocol.java:1529)
at com.sun.mail.imap.protocol.IMAPProtocol.fetch(IMAPProtocol.java:1521)
at com.sun.mail.imap.protocol.IMAPProtocol.fetchBodyStructure(IMAPProtocol.java:1221)
at com.sun.mail.imap.IMAPMessage.loadBODYSTRUCTURE(IMAPMessage.java:1307)
at com.sun.mail.imap.IMAPMessage.getDataHandler(IMAPMessage.java:623)
at javax.mail.internet.MimeMessage.getContent(MimeMessage.java:927

Thanks to anyone that can help me !
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 28 2014
Added on Nov 6 2012
8 comments
4,911 views