This is an automated email from the ASF dual-hosted git repository. huxing pushed a commit to branch 2.7.3-release in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/2.7.3-release by this push: new 3d01797 Fix MulticastSocket setInterface choose an unreachable address (#4426) 3d01797 is described below commit 3d01797afd5616cea1b13e88544c5f9312ba3c70 Author: Shoukai Huang <shou...@users.noreply.github.com> AuthorDate: Tue Jul 2 17:39:11 2019 +0800 Fix MulticastSocket setInterface choose an unreachable address (#4426) --- .../org/apache/dubbo/common/utils/NetUtils.java | 24 ++++++++++++++++------ 1 file changed, 18 insertions(+), 6 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 6fd1a4e..bef5183 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 @@ -371,13 +371,25 @@ public class NetUtils { while (addresses.hasMoreElements()) { InetAddress address = (InetAddress) addresses.nextElement(); if (preferIpv6 && address instanceof Inet6Address) { - multicastSocket.setInterface(address); - interfaceSet = true; - break; + try { + if(address.isReachable(100)){ + multicastSocket.setInterface(address); + interfaceSet = true; + break; + } + } catch (IOException e) { + // ignore + } } else if (!preferIpv6 && address instanceof Inet4Address) { - multicastSocket.setInterface(address); - interfaceSet = true; - break; + try { + if(address.isReachable(100)){ + multicastSocket.setInterface(address); + interfaceSet = true; + break; + } + } catch (IOException e) { + // ignore + } } } if (interfaceSet) {