Skip to content

[Dubbo-6733] multicast use valid network interface#6734

Merged
AlbumenJ merged 1 commit intoapache:masterfrom
AlphaLxy:multicast_valid_interface
Mar 11, 2021
Merged

[Dubbo-6733] multicast use valid network interface#6734
AlbumenJ merged 1 commit intoapache:masterfrom
AlphaLxy:multicast_valid_interface

Conversation

@AlphaLxy
Copy link
Copy Markdown

@AlphaLxy AlphaLxy commented Sep 14, 2020

What is the purpose of the change

fix #6733, multicast use valid network interface

Brief changelog

MulticastSocket should use a valid network interface, use getValidNetworkInterfaces instead of NetworkInterface.getNetworkInterfaces.

Just modified 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) {

Verifying this change

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a GITHUB_issue field for the change (usually before you start working on it). Trivial changes like typos do not require a GITHUB issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [Dubbo-XXX] Fix UnknownException when host config not exist #XXX. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add sample in dubbo samples project.
  • Run mvn clean install -DskipTests=false & mvn clean test-compile failsafe:integration-test to make sure unit-test and integration-test pass.
  • If this contribution is large, please follow the Software Donation Guide.

@AlphaLxy AlphaLxy changed the title [Dubbo-6733] multicast use valid network interface #6733 [Dubbo-6733] multicast use valid network interface Sep 14, 2020
Copy link
Copy Markdown
Member

@AlbumenJ AlbumenJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AlphaLxy AlphaLxy requested a review from AlbumenJ March 9, 2021 11:16
@AlbumenJ
Copy link
Copy Markdown
Member

@AlphaLxy could you please merge the latest master branch into this pr so we can check if the integration test work well.

@AlphaLxy AlphaLxy force-pushed the multicast_valid_interface branch from bb9b96f to 93d6c73 Compare March 11, 2021 03:50
@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #6734 (93d6c73) into master (fab59fc) will decrease coverage by 0.11%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #6734      +/-   ##
============================================
- Coverage     58.67%   58.56%   -0.12%     
+ Complexity      425      424       -1     
============================================
  Files          1044     1044              
  Lines         42484    42482       -2     
  Branches       6229     6212      -17     
============================================
- Hits          24928    24878      -50     
- Misses        14759    14802      +43     
- Partials       2797     2802       +5     
Impacted Files Coverage Δ Complexity Δ
...n/java/org/apache/dubbo/common/utils/NetUtils.java 66.66% <100.00%> (-0.23%) 0.00 <0.00> (ø)
...bo/config/event/listener/LoggingEventListener.java 37.50% <0.00%> (-25.00%) 0.00% <0.00%> (ø%)
...in/java/org/apache/dubbo/common/utils/JVMUtil.java 81.13% <0.00%> (-11.33%) 0.00% <0.00%> (ø%)
...ava/org/apache/dubbo/config/DubboShutdownHook.java 63.82% <0.00%> (-10.64%) 0.00% <0.00%> (ø%)
...che/dubbo/remoting/transport/mina/MinaChannel.java 39.47% <0.00%> (-10.53%) 15.00% <0.00%> (-1.00%)
.../registry/multicast/MulticastServiceDiscovery.java 38.46% <0.00%> (-7.70%) 0.00% <0.00%> (ø%)
...ng/transport/dispatcher/all/AllChannelHandler.java 82.75% <0.00%> (-6.90%) 0.00% <0.00%> (ø%)
.../dubbo/remoting/transport/netty4/NettyChannel.java 63.36% <0.00%> (-3.97%) 0.00% <0.00%> (ø%)
...pache/dubbo/remoting/transport/AbstractServer.java 53.75% <0.00%> (-3.75%) 0.00% <0.00%> (ø%)
.../org/apache/dubbo/qos/legacy/LogTelnetHandler.java 30.30% <0.00%> (-3.04%) 0.00% <0.00%> (ø%)
... and 11 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fab59fc...93d6c73. Read the comment docs.

@AlphaLxy
Copy link
Copy Markdown
Author

@AlphaLxy could you please merge the latest master branch into this pr so we can check if the integration test work well.

rebase and force pushed

@AlbumenJ AlbumenJ merged commit c27e912 into apache:master Mar 11, 2021
AlbumenJ added a commit to AlbumenJ/dubbo that referenced this pull request May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MulticastSocket use invalid network interface

3 participants