-
Notifications
You must be signed in to change notification settings - Fork 26.4k
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
[Dubbo-2064] Ipv6 support #2079
Changes from 2 commits
4a554bc
8a23fe3
3602e8e
0e09fb0
eb00834
cba34cd
db01ebd
9de876b
fef30cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -194,26 +194,22 @@ private static InetAddress getLocalAddress0() { | |
} | ||
try { | ||
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); | ||
if (interfaces != null) { | ||
while (interfaces.hasMoreElements()) { | ||
try { | ||
NetworkInterface network = interfaces.nextElement(); | ||
Enumeration<InetAddress> addresses = network.getInetAddresses(); | ||
if (addresses != null) { | ||
while (addresses.hasMoreElements()) { | ||
try { | ||
InetAddress address = addresses.nextElement(); | ||
if (isValidAddress(address)) { | ||
return address; | ||
} | ||
} catch (Throwable e) { | ||
logger.warn(e); | ||
} | ||
while (interfaces.hasMoreElements()) { | ||
try { | ||
NetworkInterface network = interfaces.nextElement(); | ||
Enumeration<InetAddress> addresses = network.getInetAddresses(); | ||
while (addresses.hasMoreElements()) { | ||
try { | ||
InetAddress address = addresses.nextElement(); | ||
if (isValidAddress(address)) { | ||
return address; | ||
} | ||
} catch (Throwable e) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rename e to ignored will be better |
||
logger.warn(e); | ||
} | ||
} catch (Throwable e) { | ||
logger.warn(e); | ||
} | ||
} catch (Throwable e) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rename e to ignored will be better There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, this is just coding style. I prefer to use catch (Throwable e) {
// ignore
} instead of catch(Throwable ignored) {
} I found several codes in Dubbo's code that is written in the former way, but did not find my codes that is written in the way you suggested. So I guess I am going to leave it unchanged. |
||
logger.warn(e); | ||
} | ||
} | ||
} catch (Throwable e) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should check the interfaces property null value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I am using Java 10, the implementation is different with Java 8. In Java 10 the implementation guarantees no null value is returned. I will add the null check.