Skip to content
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

Fix ConcurrentModification when initializing concurrently #10616

Merged
merged 1 commit into from
Sep 15, 2022

Conversation

guohao
Copy link
Contributor

@guohao guohao commented Sep 14, 2022

What is the purpose of the change

Fix ConcurrentModificationException when initializing dubbo concurrently.

Scenario:
Assume there are two beans A and B

  1. A is iterating PropertiesConfiguration for prefix configs.
  2. B is writing its Registry/Application/Protocol Config to PropertiesConfiguration

Cuz it is not thread-safe when iterating HashTable with put concurrently, a ConcurrentModificationException will be thrown by HashTable.

Brief changelog

Return a copied Map under sync block.

Verifying this change

Checklist

  • 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.
  • 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.
  • Check if is necessary to patch to Dubbo 3 if you are work on Dubbo 2.7
  • 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.
  • Add some description to dubbo-website project if you are requesting to add a feature.
  • GitHub Actions works fine on your own branch.
  • If this contribution is large, please follow the Software Donation Guide.

@codecov-commenter
Copy link

codecov-commenter commented Sep 14, 2022

Codecov Report

Merging #10616 (7a425fc) into 3.1 (631d3fc) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##                3.1   #10616      +/-   ##
============================================
+ Coverage     64.85%   64.87%   +0.01%     
+ Complexity      414      413       -1     
============================================
  Files          1334     1334              
  Lines         56667    56679      +12     
  Branches       8378     8379       +1     
============================================
+ Hits          36749    36768      +19     
+ Misses        15979    15973       -6     
+ Partials       3939     3938       -1     
Impacted Files Coverage Δ
...apache/dubbo/common/config/ConfigurationUtils.java 78.26% <100.00%> (+1.51%) ⬆️
...dubbo/remoting/exchange/support/DefaultFuture.java 87.93% <0.00%> (-4.32%) ⬇️
...he/dubbo/remoting/transport/netty/NettyServer.java 70.17% <0.00%> (-3.51%) ⬇️
...java/org/apache/dubbo/remoting/api/Connection.java 80.83% <0.00%> (-1.67%) ⬇️
...ng/zookeeper/curator5/Curator5ZookeeperClient.java 69.33% <0.00%> (-0.95%) ⬇️
...apache/dubbo/rpc/protocol/dubbo/DubboProtocol.java 62.45% <0.00%> (-0.71%) ⬇️
...vent/listener/ServiceInstancesChangedListener.java 76.73% <0.00%> (-0.41%) ⬇️
...org/apache/dubbo/registry/nacos/NacosRegistry.java 50.81% <0.00%> (-0.34%) ⬇️
...ubbo/registry/client/ServiceDiscoveryRegistry.java 75.95% <0.00%> (+0.54%) ⬆️
...rg/apache/dubbo/common/timer/HashedWheelTimer.java 86.25% <0.00%> (+0.68%) ⬆️
... and 9 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@EarthChen EarthChen left a comment

Choose a reason for hiding this comment

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

LGTM

@AlbumenJ AlbumenJ merged commit fdef33f into apache:3.1 Sep 15, 2022
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.

4 participants