-
Notifications
You must be signed in to change notification settings - Fork 12k
Upgrade JDK dependency and code clean based on the features of JDK 1.8 #470
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
Conversation
| if (createNew) { | ||
| // Internal class requires final variables | ||
| final AtomicBoolean createNew = new AtomicBoolean(false); | ||
| TopicConfig topicConfig = this.topicConfigTable.computeIfAbsent(topic, key -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid lock contention of lockTopicConfigTable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ConeyLiu why you polish createTopicInSendMessageBackMethod and skip createTopicInSendMessageMethod?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, @dongeforever. The lockTopicConfigTable is a global lock which can reduce the performance of ConcurrentHashMap. The computIfAbsent of ConcurrentHashMap can provide an atomic operation with better performance. This is should be an improvement.
| if (null == preConfig) { | ||
| log.info("auto create a subscription group, {}", subscriptionGroupConfig.toString()); | ||
| } | ||
| subscriptionGroupConfig = this.subscriptionGroupTable.computeIfAbsent(group, (key) -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function is only called when the value is absent. So this can avoid unnecessary object creation.
|
@ConeyLiu The client need to be compatible with 1.6. And I remember their is a compatible problem in ConcurrentHashMap, it will throw exception in 1.6 if its source is built in 1.8. |
|
@dongeforever, thanks for the review. I only upgrade the JDK dependency of server-side. And also the test is passed, seems shouldn't any compatible problem. |
|
@ConeyLiu Yeah,I have found the old pr https://github.com/apache/rocketmq/pull/110。 |
|
@ConeyLiu It seems ok to upgrade jdk to 1.8 in server side. But the community version may not upgrade it until it is sure. |
|
OK, thanks @dongeforever. It's OK to pending here if there is any concern. I'd like to contribute more to the RocketMQ. |
247e0bf to
ce4478a
Compare
|
it seems too long and conflicts exist for this PR, I will close it for time being. for any issues, welcome to create new PR to the develop branch. |
What is the purpose of the change
We have already stated in the documentation that the version of the JDK requirement is 1.8. So we should update the JDK dependency to JDK1.8.
Brief changelog
Upgrade the JDK dependency.
Code clean based on the new features of
ConcurrentHashMapin JDK 1.8.Verifying this change
Existing UT test.
Follow this checklist to help us incorporate your contribution quickly and easily. Notice,
it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR.[ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyleto make sure basic checks pass. Runmvn clean install -DskipITsto make sure unit-test pass. Runmvn clean test-compile failsafe:integration-testto make sure integration-test pass.