gosonzhang commented on a change in pull request #97:
URL: https://github.com/apache/incubator-tubemq/pull/97#discussion_r429907954
##########
File path:
tubemq-core/src/main/java/org/apache/tubemq/corebase/utils/AddressUtils.java
##########
@@ -34,31 +40,29 @@ public static synchronized String getLocalAddress() throws
Exception {
return localIPAddress;
}
- public static boolean validLocalIp(String currLocalHost) throws Exception {
+ public static boolean validLocalIp(String currLocalHost) {
if (TStringUtils.isNotEmpty(localIPAddress)
&& localIPAddress.equals(currLocalHost)) {
return true;
}
- Enumeration<NetworkInterface> allInterface =
NetworkInterface.getNetworkInterfaces();
- if (allInterface == null) {
- throw new Exception("Get NetworkInterfaces is null");
- }
+
+ Enumeration<NetworkInterface> allInterface = listNetworkInterface();
+
return checkValidIp(allInterface, currLocalHost);
}
- private static boolean checkValidIp(Enumeration<NetworkInterface>
allInterface,
- String currLocalHost) throws Exception
{
- String localIp = null;
+ private static boolean checkValidIp(Enumeration<NetworkInterface>
allInterface, String currLocalHost) {
Review comment:
It is possible that the user prefers to obtain IP addresses from a
certain network card first, and then the IPV4 type address is the best choice,
so can the function achieve such an effect:
1. the program first obtains the IP address from the specified network card,
and prefers the IPV4 address;
2. the specified network card does not Get IP from other network card when
IPV4 address;
3. if there are no IPV4 address, I choose IPV6;
4. when all network cards can not get IP address, then get from InetAddress
object?
----------------------------------------------------------------
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]