com.sun.mail.iap.ParsingException:BODYSTRUCTURE解析错误:错误的``大小''元素

时间:2019-05-24 07:33:34

标签: java javamail imap

我正在尝试从电子邮件收件箱中读取退回邮件,但总是收到以下异常:

2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com) DEBUG IMAPS: ignoring bad response, THROW: 
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com) com.sun.mail.iap.ParsingException: BODYSTRUCTURE parse error: bad ``size'' element
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at com.sun.mail.imap.protocol.BODYSTRUCTURE.<init>(BODYSTRUCTURE.java:266)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at com.sun.mail.imap.protocol.BODYSTRUCTURE.<init>(BODYSTRUCTURE.java:291)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at com.sun.mail.imap.protocol.BODYSTRUCTURE.<init>(BODYSTRUCTURE.java:110)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at com.sun.mail.imap.protocol.FetchResponse.parseItem(FetchResponse.java:258)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at com.sun.mail.imap.protocol.FetchResponse.parse(FetchResponse.java:213)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at com.sun.mail.imap.protocol.FetchResponse.<init>(FetchResponse.java:96)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at com.sun.mail.imap.protocol.IMAPProtocol.readResponse(IMAPProtocol.java:392)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at com.sun.mail.iap.Protocol.command(Protocol.java:354)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at com.sun.mail.imap.protocol.IMAPProtocol.fetch(IMAPProtocol.java:2113)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at com.sun.mail.imap.protocol.IMAPProtocol.fetch(IMAPProtocol.java:2105)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at com.sun.mail.imap.protocol.IMAPProtocol.fetchBodyStructure(IMAPProtocol.java:1680)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at com.sun.mail.imap.IMAPMessage.loadBODYSTRUCTURE(IMAPMessage.java:1476)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at com.sun.mail.imap.IMAPMessage.getDataHandler(IMAPMessage.java:746)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at javax.mail.internet.MimeMessage.getContent(MimeMessage.java:1454)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at org.apache.camel.component.mail.MailBinding.extractBodyFromMail(MailBinding.java:250)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at org.apache.camel.component.mail.MailMessage.createBody(MailMessage.java:105)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at org.apache.camel.component.mail.MailMessageRobust.createBody(MailMessageRobust.java:39)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:47)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at org.apache.camel.component.mail.MailConsumer.createExchanges(MailConsumer.java:354)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at org.apache.camel.component.mail.MailConsumer.poll(MailConsumer.java:128)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:175)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:102)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPool
Executor.java:180)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecuto
r.java:294)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
2019-05-23 16:05:42 INFO  [stdio.AbstractLoggingWriter] (Camel (camel-inbound) thread #24 - robustimaps://abc@test.com)       at java.lang.Thread.run(Thread.java:748)

我试图在Internet上查找该错误的含义,但实际上并没有得到任何有用的结果。对该方向的任何建议或提示都会有所帮助。

谢谢!

从@arnt阅读评论后,我提取了引发此错误的响应,如下所示:

robustimaps://abc@test.com) * 1 FETCH (BODYSTRUCTURE (((("text" "plain" ("charset" "UTF-8") NIL NIL "7BIT" 143 7 NIL NIL NIL NIL)("text"
 "html" ("charset" "UTF-8") NIL NIL "7BIT" 1209 33 NIL NIL NIL NIL) "alternative" ("boundary" "0000000000006a31d605898e6fe4") NIL NIL)("image" "png" ("name" "icon.png") "<icon.png>" NIL "base64" 7864 NIL ("attachment" ("filename" 
"icon.png")) NIL NIL) "related" ("boundary" "0000000000006a31d305898e6fe3") NIL NIL)("message" "delivery-status" NIL NIL NIL "7BIT" 355 NIL NIL NIL NIL)("message" "rfc822" NIL NIL NIL "7BIT" 0 ("Thu, 23 May 2019 15:55:30 +0200" "=
?UTF-8?Q?Ihr_blah_blah_blah_bald._when_and_where_m=C3=B6c?= =?UTF-8?Q?hten_Sie_es_empfangen=3F_Jetzt_festlegen_...?=" (("ABC Paket" NIL "abc" "test.com")) NIL (("ABC Paket" NIL "abc" "test.com")) ((NIL NIL "3011941477" "xyz.
de")) NIL NIL NIL "<2066153904.661086.1558619730208@rnd-02.broadmail.live>") ("multipart" "signed" ("protocol" "application/pkcs7-signature" "micalg" "sha-256" "boundary" "----=_Part_661085_623173410.1558619730208") NIL NIL "7BIT"
 -1 NIL NIL NIL NIL) 0 NIL NIL NIL NIL) "report" ("boundary" "0000000000006a30fa05898e6fdb" "report-type" "delivery-status") NIL NIL))

1 个答案:

答案 0 :(得分:0)

Javamail正在解析一个主体结构,这是一个很长的行,其中包含许多括号,数字,NIL和字符串。在预期大小的点上,它发现负数。为什么那里有一个负数?好吧,IMAP服务器没有太多发送负数的机会,因此我怀疑服务器存在错误。

(为完整性起见:另一种选择是,服务器的编号正确,并且客户端当时无法期望大小。但是现在我们知道这是服务器错误。)