<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">I suspect that this is the wrong list; please redirect me if so.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The docs for this method:<o:p></o:p></p>
<p class="MsoNormal"><a href="https://docs.oracle.com/en/java/javase/18/docs/api/java.base/java/net/InetAddress.html#getLocalHost()">https://docs.oracle.com/en/java/javase/18/docs/api/java.base/java/net/InetAddress.html#getLocalHost()</a><o:p></o:p></p>
<p class="MsoNormal">say that it “Returns the address of the local host. This is achieved by retrieving the name of the host from the system, then resolving that name into an InetAddress.”<o:p></o:p></p>
<p class="MsoNormal">This is true enough in simple cases, but horribly misleading in non-trivial cases.<o:p></o:p></p>
<p class="MsoNormal">As far as I can tell it can’t return “the address” because the local host may have multiple addresses.<o:p></o:p></p>
<p class="MsoNormal">Instead it returns “an address” of the local host. My laptop right now has 3 addresses: IPv6 loopback, IPv4 from home WiFi, and IPv4 from company network via VPN.<o:p></o:p></p>
<p class="MsoNormal">As far as I can tell (please correct me if I’m wrong!!) if there are multiple addresses, the current implementation makes no effort to pick a more “useful” one.<o:p></o:p></p>
<p class="MsoNormal">Instead, it takes whatever addresses it gets from the OS and returns the first one.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thus, in theory, and even in practice, it’s perfectly possible to get into a situation where all of the following hold:<o:p></o:p></p>
<p class="MsoNormal">“It worked fine yesterday!”<o:p></o:p></p>
<p class="MsoNormal">“I didn’t change anything, honest!”<o:p></o:p></p>
<p class="MsoNormal">And yet, “nothing works today” (because, unbeknownst to mere mortals like me, the OS happened to return things in a different order today.)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Again, please correct me if I’m wrong and there actually are some guarantees, either by virtue of the spec, or by virtue of “it just so happens that in practice you will tend to get XYZ”.<o:p></o:p></p>
<p class="MsoNormal">But if I’m right, then I suggest the following tweak to the documentation:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Returns the address of the local host. If the local host has multiple addresses, an arbitrary one will be chosen and returned.<o:p></o:p></p>
<p class="MsoNormal">This is achieved by retrieving the name of the host from the system, then resolving that name into a list of one or more `InetAddress`es and then choosing an arbitrary address from that list.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">(irrelevant but: really wish Javadoc had a lightweight notation for code like markdown’s `code(blocks)`)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Just my two cents. Again, please redirect me if this is the wrong list, and correct me if I’m wrong re: no guarantees about which address is returned.<o:p></o:p></p>
</div>
<P><SPAN lang=EN-US style="mso-ansi-language: EN-US">This message is for
information purposes only. It is not a recommendation, advice, offer or
solicitation to buy or sell a product or service, nor an official confirmation
of any transaction. It is directed at persons who are professionals and is
intended for the recipient(s) only. It is not directed at retail customers. This
message is subject to the terms at: <A
href="https://www.cib.barclays/disclosures/web-and-email-disclaimer.html">https://www.cib.barclays/disclosures/web-and-email-disclaimer.html</A>.
</SPAN></P>
<P><SPAN lang=EN-US style="mso-ansi-language: EN-US">For important disclosures,
please see: <A
href="https://www.cib.barclays/disclosures/sales-and-trading-disclaimer.html">https://www.cib.barclays/disclosures/sales-and-trading-disclaimer.html</A>
regarding marketing commentary from Barclays Sales and/or Trading desks, who are
active market participants; <A
href="https://www.cib.barclays/disclosures/barclays-global-markets-disclosures.html">https://www.cib.barclays/disclosures/barclays-global-markets-disclosures.html</A>
regarding our standard terms for Barclays Corporate and Investment Bank where we
trade with you in principal-to-principal wholesale markets transactions; and in
respect to Barclays Research, including disclosures relating to specific
issuers, see: <A
href="http://publicresearch.barclays.com">http://publicresearch.barclays.com</A>.<BR>__________________________________________________________________________________
<BR>If you are incorporated or operating in Australia, read these important
disclosures: <A
href="https://www.cib.barclays/disclosures/important-disclosures-asia-pacific.html">https://www.cib.barclays/disclosures/important-disclosures-asia-pacific.html</A>.<BR>__________________________________________________________________________________<BR>For
more details about how we use personal information, see our privacy notice: <A
href="https://www.cib.barclays/disclosures/personal-information-use.html">https://www.cib.barclays/disclosures/personal-information-use.html</A>.
<BR>__________________________________________________________________________________<BR></O:P></SPAN></P>
</body>
</html>