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

[improve]improve code #2523

Merged
merged 12 commits into from
Aug 31, 2024
Merged

[improve]improve code #2523

merged 12 commits into from
Aug 31, 2024

Conversation

zhangshenghang
Copy link
Member

What's changed?

improve code

Checklist

Comment on lines 75 to 78
public JmxCollectImpl() {
connectionCommonCache = new ConnectionCommonCache<>();
Thread.currentThread().setContextClassLoader(new ClassLoaderConfig(ClassLoader.getSystemClassLoader()));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi, this seem can not work due the constructor new JmxCollectImpl() is call by the thread-A and JmxCollectImpl is singleton, but the JmxCollectImpl.collect is run by another thread-B in running-thread-pool. Thread.currentThread().setContextClassLoader only can take effect on the current thread.

Signed-off-by: tomsun28 <tomsun28@outlook.com>
Signed-off-by: tomsun28 <tomsun28@outlook.com>
@codecov-commenter
Copy link

codecov-commenter commented Aug 18, 2024

Codecov Report

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

Project coverage is 28.62%. Comparing base (19955fa) to head (a1d7dd6).

Files with missing lines Patch % Lines
...ertzbeat/collector/collect/jmx/JmxClassLoader.java 0.00% 9 Missing ⚠️
...ertzbeat/collector/collect/jmx/JmxCollectImpl.java 0.00% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #2523      +/-   ##
============================================
- Coverage     28.65%   28.62%   -0.03%     
+ Complexity     1640     1639       -1     
============================================
  Files           445      446       +1     
  Lines         18121    18133      +12     
  Branches       2338     2339       +1     
============================================
- Hits           5192     5191       -1     
- Misses        12340    12354      +14     
+ Partials        589      588       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@tomsun28 tomsun28 left a comment

Choose a reason for hiding this comment

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

lgtm.👍

@tomsun28 tomsun28 merged commit 7bb049f into master Aug 31, 2024
2 of 3 checks passed
@zqr10159 zqr10159 deleted the improve-code branch September 23, 2024 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants