You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2021/03/11 14:40:11 UTC

[dubbo] branch master updated: fix #6733, multicast use valid network interface (#6734)

This is an automated email from the ASF dual-hosted git repository.

albumenj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/master by this push:
     new c27e912  fix #6733, multicast use valid network interface (#6734)
c27e912 is described below

commit c27e912add8458068e4ba8eb78005de4bd20a753
Author: Xinyu Liu <li...@163.com>
AuthorDate: Thu Mar 11 22:39:57 2021 +0800

    fix #6733, multicast use valid network interface (#6734)
    
    Co-authored-by: tieqin.lxy <ti...@alibaba-inc.com>
---
 .../src/main/java/org/apache/dubbo/common/utils/NetUtils.java       | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/NetUtils.java b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/NetUtils.java
index 1845514..b10e6cb 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/NetUtils.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/NetUtils.java
@@ -471,10 +471,8 @@ public class NetUtils {
 
     public static void setInterface(MulticastSocket multicastSocket, boolean preferIpv6) throws IOException {
         boolean interfaceSet = false;
-        Enumeration interfaces = NetworkInterface.getNetworkInterfaces();
-        while (interfaces.hasMoreElements()) {
-            NetworkInterface i = (NetworkInterface) interfaces.nextElement();
-            Enumeration addresses = i.getInetAddresses();
+        for (NetworkInterface networkInterface : getValidNetworkInterfaces()) {
+            Enumeration addresses = networkInterface.getInetAddresses();
             while (addresses.hasMoreElements()) {
                 InetAddress address = (InetAddress) addresses.nextElement();
                 if (preferIpv6 && address instanceof Inet6Address) {