Skip to content

Commit f33f6b2

Browse files
committed
add windows support
1 parent 087a785 commit f33f6b2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

core/src/main/scala/org/apache/spark/util/Utils.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,10 @@ private[spark] object Utils extends Logging {
495495
// a better address using the local network interfaces
496496
// getNetworkInterfaces returns ifs in reverse order compared to ifconfig output order
497497
// on unix-like system. On windows, it returns in index order.
498-
// It's more proper to pick ip address following the ifconfig output order
499-
for (ni <- NetworkInterface.getNetworkInterfaces.toList.reverse) {
498+
// It's more proper to pick ip address following system output order.
499+
val activeNetworkIFs = NetworkInterface.getNetworkInterfaces.toList
500+
val reOrderedNetworkIFs = if (isWindows) activeNetworkIFs else activeNetworkIFs.reverse
501+
for (ni <- reOrderedNetworkIFs) {
500502
for (addr <- ni.getInetAddresses if !addr.isLinkLocalAddress &&
501503
!addr.isLoopbackAddress && addr.isInstanceOf[Inet4Address]) {
502504
// We've found an address that looks reasonable!

0 commit comments

Comments
 (0)