启用断言时,JavaMail 1.4 总是抛出 AssertionError (-ea)
JavaMail 1.4 always throws AssertionError when assertions are enabled (-ea)
使用旧版本的 JavaMail 1.4 时,启用 JVM 运行 断言 -ea
,JavaMail 总是在连接到 SMTP 服务器时抛出 AssertionError
:
Caused by: java.lang.AssertionError
at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1578)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1369)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412)
at javax.mail.Service.connect(Service.java:251)
AssertionError
完全出乎意料,我希望连接能够正常工作,并且在没有启用 JVM 断言的情况下也能正常工作。
除了放弃 运行 个断言之外,还有什么办法可以解决这个错误吗?
您需要升级到更新的或最新的 JavaMail。这看起来像是一个旧错误,此错误已在 JavaMail 参考实现中修复,修复 post 版本 1.4.
正在审核 SMTPTransport source code , it performs a lot of assertions checking that the code is holding the current monitor/lock on itself. One of the methods was missing the synchronized keyword, making this untrue, resulting in an AssertionError
, but only if assertions are explicitly enabled. It looks like the method missing the synchronization block was fixed in this revision。
最简单的做法是升级到更新的 JavaMail,或者禁用断言。
使用旧版本的 JavaMail 1.4 时,启用 JVM 运行 断言 -ea
,JavaMail 总是在连接到 SMTP 服务器时抛出 AssertionError
:
Caused by: java.lang.AssertionError
at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1578)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1369)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412)
at javax.mail.Service.connect(Service.java:251)
AssertionError
完全出乎意料,我希望连接能够正常工作,并且在没有启用 JVM 断言的情况下也能正常工作。
除了放弃 运行 个断言之外,还有什么办法可以解决这个错误吗?
您需要升级到更新的或最新的 JavaMail。这看起来像是一个旧错误,此错误已在 JavaMail 参考实现中修复,修复 post 版本 1.4.
正在审核 SMTPTransport source code , it performs a lot of assertions checking that the code is holding the current monitor/lock on itself. One of the methods was missing the synchronized keyword, making this untrue, resulting in an AssertionError
, but only if assertions are explicitly enabled. It looks like the method missing the synchronization block was fixed in this revision。
最简单的做法是升级到更新的 JavaMail,或者禁用断言。