This repository was archived by the owner on Aug 20, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
mail/src/main/java/javax/mail/internet Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ K 7238 unsolicited FETCH response *must* invalidate X-GM-LABELS in cache
2929K 7332 MimeBodyPart.isMimeType returns false if type header can't be parsed
3030K 7356 NPE in Tomcat ClassLoader causes Session.getInstance to fail
3131K 7378 Deadlock in IMAPFolder.doProtocolCommand()
32+ K 7471 InternetAddress.getLocalAddress should use
33+ InetAddress.getCanonicalHostName
3234
3335
3436 CHANGES IN THE 1.5.5 RELEASE
Original file line number Diff line number Diff line change @@ -14,6 +14,18 @@ implementation. This note summarizes potential compatibility issues
1414with this release of the JavaMail API.
1515
1616
17+ -- JavaMail 1.5.6 --
18+
19+ - InternetAddress.getLocalAddress uses canonical host name
20+
21+ The InternetAddress.getLocalAddress method now uses the
22+ java.net.InetAddress.getCanonicalHostName method if neither the
23+ "mail.from" nor "mail.host" properties have been set. The System
24+ property "mail.mime.address.usecanonicalhostname" can be set to
25+ "false" to revert to the previous behavior.
26+
27+
28+
1729-- JavaMail 1.5.4 --
1830
1931- Idlemanager.watch no longer throws IOException
Original file line number Diff line number Diff line change @@ -85,6 +85,10 @@ public class InternetAddress extends Address implements Cloneable {
8585 PropUtil .getBooleanSystemProperty (
8686 "mail.mime.address.ignorebogusgroupname" , true );
8787
88+ private static final boolean useCanonicalHostName =
89+ PropUtil .getBooleanSystemProperty (
90+ "mail.mime.address.usecanonicalhostname" , true );
91+
8892 /**
8993 * Default constructor.
9094 */
@@ -567,7 +571,14 @@ private static String getLocalHostName() throws UnknownHostException {
567571 String host = null ;
568572 InetAddress me = InetAddress .getLocalHost ();
569573 if (me != null ) {
570- host = me .getHostName ();
574+ // try canonical host name first
575+ if (useCanonicalHostName )
576+ host = me .getCanonicalHostName ();
577+ if (host == null )
578+ host = me .getHostName ();
579+ // if we can't get our name, use local address literal
580+ if (host == null )
581+ host = me .getHostAddress ();
571582 if (host != null && host .length () > 0 && isInetAddressLiteral (host ))
572583 host = '[' + host + ']' ;
573584 }
Original file line number Diff line number Diff line change 55
66 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
77
8- Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
8+ Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
99
1010 The contents of this file are subject to the terms of either the GNU
1111 General Public License Version 2 only ("GPL") or the Common Development
@@ -542,6 +542,25 @@ <H4>Properties</H4>
542542</ TD >
543543</ TR >
544544
545+ < A NAME ="mail.mime.address.usecanonicalhostname "> </ A >
546+ < TR id ="mail.mime.address.usecanonicalhostname ">
547+ < TD > mail.mime.address.usecanonicalhostname</ TD >
548+ < TD > boolean</ TD >
549+ < TD >
550+ Use the
551+ {@link java.net.InetAddress#getCanonicalHostName InetAddress.getCanonicalHostName}
552+ method to determine the host name in the
553+ {@link javax.mail.internet.InternetAddress#getLocalAddress InternetAddress.getLocalAddress}
554+ method.
555+ With some network configurations, InetAddress.getCanonicalHostName may be
556+ slow or may return an address instead of a host name.
557+ In that case, setting this System property to false will cause the
558+ {@link java.net.InetAddress#getHostName InetAddress.getHostName}
559+ method to be used instead.
560+ The default is true.
561+ </ TD >
562+ </ TR >
563+
545564</ TABLE >
546565< P >
547566The current
You can’t perform that action at this time.
0 commit comments