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

[ISSUE#12583] ProtocolManager代码优化 #12584

Merged
merged 2 commits into from
Sep 3, 2024

Conversation

HMYDK
Copy link
Contributor

@HMYDK HMYDK commented Sep 2, 2024

What is the purpose of the change

fix #12583 ProtocolManager可能导致的并发问题

Brief changelog

  • getCpProtocol()和getApProtocol()的内部实现不再锁住当前对象
  • volatile修饰apInit和cpInit
  • 修改ApplicationUtils.getBeanIfExist,保证异常正常抛出

Verifying this change

XXXX

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

  • Make sure there is a Github issue filed 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 [ISSUE #123] Fix UnknownException when host config not exist. 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 integration-test in test module.
  • Run mvn -B clean package apache-rat:check findbugs:findbugs -Dmaven.test.skip=true to make sure basic checks pass. Run mvn clean install -DskipITs to make sure unit-test pass. Run mvn clean test-compile failsafe:integration-test to make sure integration-test pass.

@codecov-commenter
Copy link

codecov-commenter commented Sep 2, 2024

Codecov Report

Attention: Patch coverage is 0% with 14 lines in your changes missing coverage. Please review.

Project coverage is 69.65%. Comparing base (98a6e22) to head (26c440f).
Report is 11 commits behind head on develop.

Files with missing lines Patch % Lines
...libaba/nacos/core/distributed/ProtocolManager.java 0.00% 14 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             develop   #12584   +/-   ##
==========================================
  Coverage      69.64%   69.65%           
- Complexity      9418     9422    +4     
==========================================
  Files           1275     1275           
  Lines          41226    41232    +6     
  Branches        4373     4374    +1     
==========================================
+ Hits           28712    28719    +7     
+ Misses         10435    10432    -3     
- Partials        2079     2081    +2     
Files with missing lines Coverage Δ
...libaba/nacos/core/distributed/ProtocolManager.java 10.00% <0.00%> (-0.61%) ⬇️

... and 5 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

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

Copy link
Collaborator

@KomachiSion KomachiSion left a comment

Choose a reason for hiding this comment

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

ProtocolManager的修改可以采纳。麻烦修改下

consumer.accept(bean);
} catch (NoSuchBeanDefinitionException ignore) {
}
T bean = applicationContext.getBean(requiredType);
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个修改不合理, 本身语义就是希望不存在时创建, 不影响后续逻辑本身, 显示抛出异常不符合方法语义。

Copy link
Collaborator

Choose a reason for hiding this comment

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

其他类型的异常时正常抛出的, 只有不存在bean的异常会被捕获。

@KomachiSion KomachiSion added the kind/enhancement Category issues or prs related to enhancement. label Sep 3, 2024
@KomachiSion KomachiSion added this to the 2.4.2 milestone Sep 3, 2024
@KomachiSion KomachiSion merged commit 62f4a37 into alibaba:develop Sep 3, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Category issues or prs related to enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ProtocolManager可能导致的并发问题
3 participants