demery-pivotal commented on a change in pull request #5680:
URL: https://github.com/apache/geode/pull/5680#discussion_r521693520
##########
File path:
geode-common/src/main/java/org/apache/geode/internal/inet/LocalHostUtil.java
##########
@@ -54,70 +59,80 @@
private static final boolean useLinkLocalAddresses =
Boolean.getBoolean(USE_LINK_LOCAL_ADDRESSES_PROPERTY);
- /**
- * we cache localHost to avoid bug #40619, access-violation in native code
- */
- private static final InetAddress localHost;
-
/**
* all classes should use this variable to determine whether to use IPv4 or
IPv6 addresses
*/
@MakeNotStatic
private static boolean useIPv6Addresses =
!Boolean.getBoolean("java.net.preferIPv4Stack")
&& Boolean.getBoolean("java.net.preferIPv6Addresses");
- static {
- InetAddress inetAddress = null;
+ /**
+ * Resolves local host. Will retry if resolution fails.
+ *
+ * @return local host if resolved otherwise null.
+ */
+ private static InetAddress resolveLocalHost() {
Review comment:
If you want to test, you can create an overload that takes suppliers,
functions, and predicates to call instead of calling static methods, then mock
those things to drive the desired test conditions. Then `resolveLocalHost()`
could simply call the overloaded one, passing references to the static methods,
and we would leave that untested.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]