Skip to content

fix concurrent bug (avoid NullPointerException)#6102

Closed
Augustvic wants to merge 2 commits intoapache:masterfrom
Augustvic:master
Closed

fix concurrent bug (avoid NullPointerException)#6102
Augustvic wants to merge 2 commits intoapache:masterfrom
Augustvic:master

Conversation

@Augustvic
Copy link
Copy Markdown
Contributor

@Augustvic Augustvic commented May 5, 2020

What is the purpose of the change

Resolve concurrent bug (or NullPointerException) in DubboProtocol.java

Brief changelog

The statement "locks.get(key)" will get NULL after "locks.remove(key);", and then "synchronized(null)" will throw NullPointerException. Obviously, this two statement, "locks.putIfAbsent(key, new Object());" and "locks.get(key)", are not an atomic operation.

I can't find a better way to reduce lock granularity, maybe we have to sacrifice some performance to ensure safety here.

Verifying this change

XXXXX

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.

@Augustvic Augustvic changed the title Resolve Concurrent Bug (or NullPointerException) fix concurrent bug (avoid NullPointerException) May 28, 2020
@AlbumenJ
Copy link
Copy Markdown
Member

@Augustvic hi, thanks for your contribution.

The issue you mentioned has been resolved via #6793.

Also, it would cause performance problems if you use synchronized for referenceClientMap. This will reduce the number of concurrent.

Please feel free to reopen this pr if you still have any question, also you can create a new pr for related code.

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.

2 participants