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

InterruptedException should not be ignored #5515

Merged
merged 2 commits into from
Nov 17, 2022

Conversation

asia-zengtao
Copy link
Contributor

InterruptedException should not be ignored
print InterruptedException message and Restore interrupted state

Make sure set the target branch to develop

What is the purpose of the change

InterruptedException should not be ignored

Brief changelog

print InterruptedException message and Restore interrupted state

Verifying this change

try {
scheduledExecutorService.awaitTermination(5000, TimeUnit.MILLISECONDS);
} catch (InterruptedException ignore) {
BrokerController.LOG.warn("shutdown ScheduledExecutorService was Interrupted! ", ignore);
Thread.currentThread().interrupt();
}

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.

  • 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(over 80% coverage) 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 apache-rat:check findbugs:findbugs checkstyle:checkstyle 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.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

InterruptedException should not be ignored  
print InterruptedException  message and  Restore interrupted state
@mxsm
Copy link
Member

mxsm commented Nov 12, 2022

Hi @asia-zengtao you should create issue first, This issue describes the problem and explains why. then submit a PR to fixed, you can see this docmuent how the PR related issue.
https://docs.github.com/cn/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue

@hzh0425
Copy link
Member

hzh0425 commented Nov 13, 2022

Welcome !

@lizhanhui
Copy link
Contributor

InterruptedException is a key approach to enhance program responsiveness... As this article points out, different ways of handling are required according to specific use cases. Unfortunately, most interrupted exceptions in the codebase are simply ignored, leaving a major place to improve.

Glad to see that you point this issue out and attempt to improve.

Copy link
Contributor

@tsunghanjacktsai tsunghanjacktsai left a comment

Choose a reason for hiding this comment

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

Hi @asia-zengtao ,

Great work and welcome to the RocketMQ community. Hope you could keep making our codebase better.

hzh0425
hzh0425 previously approved these changes Nov 15, 2022
Copy link
Member

@mxsm mxsm left a comment

Choose a reason for hiding this comment

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

Code format needs modify.

Comment on lines 1426 to 1427
BrokerController.LOG.warn("shutdown ScheduledExecutorService was Interrupted! ", ignore);
Thread.currentThread().interrupt();
Copy link
Member

Choose a reason for hiding this comment

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

https://github.com/apache/rocketmq/actions/runs/3449152754/jobs/5767526841
Error: /home/runner/work/rocketmq/rocketmq/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java:1427:9: File contains tab characters (this is the first instance). [FileTabCharacter]
Error: /home/runner/work/rocketmq/rocketmq/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java:1427:17: 'catch' child has incorrect indentation level 16, expected level should be 12. [Indentation]

Here has some problems need to fix in CI.

@codecov-commenter
Copy link

Codecov Report

Merging #5515 (3abdf0a) into develop (a5b40fb) will decrease coverage by 0.51%.
The diff coverage is 40.62%.

@@              Coverage Diff              @@
##             develop    #5515      +/-   ##
=============================================
- Coverage      42.92%   42.41%   -0.52%     
+ Complexity      8069     7930     -139     
=============================================
  Files           1029     1020       -9     
  Lines          72662    71145    -1517     
  Branches        9604     9381     -223     
=============================================
- Hits           31191    30176    -1015     
+ Misses         37527    37152     -375     
+ Partials        3944     3817     -127     
Impacted Files Coverage Δ
...ava/org/apache/rocketmq/acl/common/Permission.java 92.68% <ø> (ø)
...apache/rocketmq/acl/plain/PlainAccessResource.java 57.57% <ø> (ø)
...pache/rocketmq/acl/plain/PlainAccessValidator.java 78.57% <ø> (ø)
...che/rocketmq/acl/plain/PlainPermissionManager.java 78.22% <ø> (-0.54%) ⬇️
...apache/rocketmq/broker/BrokerPreOnlineService.java 0.00% <ø> (ø)
...java/org/apache/rocketmq/broker/BrokerStartup.java 8.00% <ø> (+0.25%) ⬆️
...ache/rocketmq/broker/client/ConsumerGroupInfo.java 68.46% <ø> (ø)
...roker/client/DefaultConsumerIdsChangeListener.java 40.74% <ø> (ø)
...ache/rocketmq/broker/client/net/Broker2Client.java 6.83% <ø> (ø)
...he/rocketmq/broker/controller/ReplicasManager.java 43.09% <ø> (ø)
... and 694 more

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

@lizhanhui lizhanhui merged commit 2f7bdda into apache:develop Nov 17, 2022
drpmma pushed a commit that referenced this pull request Feb 21, 2023
* InterruptedException should not be ignored 

InterruptedException should not be ignored  
print InterruptedException  message and  Restore interrupted state

* Fix checkstyle issue

Co-authored-by: Li Zhanhui <lizhanhui@gmail.com>
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.

6 participants