Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix potential slow/hanging host resolution when sending mail #358

Closed
marcelmay opened this issue Jan 4, 2021 · 0 comments
Closed

Fix potential slow/hanging host resolution when sending mail #358

marcelmay opened this issue Jan 4, 2021 · 0 comments
Assignees
Milestone

Comments

@marcelmay
Copy link
Member

On MacOS, it can happen that name resolution hangs eg when sending mail:

"main" #1 prio=5 os_prio=31 tid=0x00007fa40f00c800 nid=0x1603 runnable [0x0000700008e3c000]
   java.lang.Thread.State: RUNNABLE
	at java.net.Inet4AddressImpl.getHostByAddr(Native Method)
	at java.net.InetAddress$2.getHostByAddr(InetAddress.java:933)
	at java.net.InetAddress.getHostFromNameService(InetAddress.java:618)
	at java.net.InetAddress.getCanonicalHostName(InetAddress.java:589)
	at javax.mail.internet.InternetAddress.getLocalHostName(InternetAddress.java:655)
	at javax.mail.internet.InternetAddress._getLocalAddress(InternetAddress.java:630)
	at javax.mail.internet.InternetAddress.getLocalAddress(InternetAddress.java:601)
	at javax.mail.internet.UniqueValue.getUniqueMessageIDValue(UniqueValue.java:76)
	at javax.mail.internet.MimeMessage.updateMessageID(MimeMessage.java:2211)
	at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:2242)
	- locked <0x00000007b571b160> (a javax.mail.internet.MimeMessage)
	at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:2198)
	at javax.mail.Transport.send(Transport.java:99)
	at com.icegreen.greenmail.util.GreenMailUtil.sendMimeMessage(GreenMailUtil.java:263)

This happens even with host IPv4 and IPv6 entries in /etc/hosts.

This fix avoids the lookup by setting mail.host property to configured mail server. See jakarta.mail.internet.InternetAddress#_getLocalAddress.

@marcelmay marcelmay added this to the 1.6.2 milestone Jan 4, 2021
@marcelmay marcelmay self-assigned this Jan 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant