Skip to content

[ISSUE #3830] InterruptedExceptions should not be ignored in the code. #4791

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

Merged
merged 5 commits into from
Mar 22, 2024

Conversation

jevinjiang
Copy link
Contributor

Fixes #3830

Motivation
Add catch InterruptedException and ThreadDeath exceptions in the code.

Modifications
Documentation

  • Does this pull request introduce a new feature? no

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome to the Apache EventMesh community!!
This is your first PR in our project. We're very excited to have you onboard contributing. Your contributions are greatly appreciated!

Please make sure that the changes are covered by tests.
We will be here shortly.
Let us know if you need any help!

Want to get closer to the community?

WeChat Assistant WeChat Public Account Slack
Join Slack Chat

Mailing Lists:

Name Description Subscribe Unsubscribe Archive
Users User support and questions mailing list Subscribe Unsubscribe Mail Archives
Development Development related discussions Subscribe Unsubscribe Mail Archives
Commits All commits to repositories Subscribe Unsubscribe Mail Archives
Issues Issues or PRs comments and reviews Subscribe Unsubscribe Mail Archives

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.

@jevinjiang Thanks for you contribution. Please fix ci, the code style

@jevinjiang
Copy link
Contributor Author

Sorry, I didn't notice before, but now it has passed the checkStyle @mxsm

Copy link

codecov bot commented Mar 18, 2024

Codecov Report

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

Project coverage is 16.33%. Comparing base (0250a89) to head (58651cf).
Report is 1 commits behind head on master.

❗ Current head 58651cf differs from pull request most recent head ab06b18. Consider uploading reports for the commit ab06b18 to get more accurate results

Files Patch % Lines
...ntmesh/storage/rocketmq/producer/ProducerImpl.java 0.00% 26 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             master    #4791       +/-   ##
=============================================
+ Coverage          0   16.33%   +16.33%     
- Complexity        0     1735     +1735     
=============================================
  Files             0      856      +856     
  Lines             0    31269    +31269     
  Branches          0     2699     +2699     
=============================================
+ Hits              0     5108     +5108     
- Misses            0    25683    +25683     
- Partials          0      478      +478     

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

} catch (InterruptedException e) {
log.error("Send message InterruptedException", e);
Thread.currentThread().interrupt(); // Restore interrupted status
throw this.checkProducerException(msg.getTopic(), messageId, e);
Copy link
Member

Choose a reason for hiding this comment

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

Since you have chosen to re-interrupt, is there no need to throw an exception again? Moreover, the throws are all non-InterruptedExceptions.

既然您选择了重新中断是不是就没必要再抛异常了?更何况抛出都是一些非InterruptedException

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I don't throw an exception, I will return a SendResult, so I chose to throw a StorageRuntimeException. Is there any better way? I can continue to modify it. 不抛出异常的话,就要返回一个SendResult,所以我选择了抛出一个StorageRuntimeException, 还有什么更好的做法没,我可以继续修改

Copy link
Member

@pandaapo pandaapo Mar 19, 2024

Choose a reason for hiding this comment

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

I think you can either return an empty SendResult, or you can use the other way of handling InterruptedException mentioned in the issue, "InterruptedExceptions should either be rethrown - immediately...".

我觉得您可以返回空的SendResult,或者采用issue中提到的另一中处理InterruptedException的方式“直接抛出中断异常”。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, it's done. Thank you for your guidance in helping me complete the first issue。 已经修改完毕,感谢您帮我完成第一个issue。

@jevinjiang jevinjiang requested a review from pandaapo March 19, 2024 10:57
@@ -68,7 +68,7 @@ public void setExtFields() {
super.getRocketmqProducer().setCompressMsgBodyOverHowmuch(10);
}

public SendResult send(CloudEvent cloudEvent) {
public SendResult send(CloudEvent cloudEvent) throws InterruptedException {
Copy link
Member

Choose a reason for hiding this comment

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

Your modification is not much different from the original code, because the catch here does not throw InterruptedException, so it still swallows InterruptedException. What I mean is to throw InterruptedException directly in catch(InterruptedException) or return empty SendResult in catch(InterruptedException).

您这样修改和原代码区别不大,因为这里的catch不会抛出InterruptedException,所以还是将InterruptedException吞掉了。我的意思是在catch(InterruptedException)中直接抛出InterruptedException或者返回空的SendResult

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm very sorry again. QAQ

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.

LGTM

@mxsm mxsm merged commit 6fa6f91 into apache:master Mar 22, 2024
9 checks passed
@xwm1992 xwm1992 added this to the 1.11.0 milestone Dec 18, 2024
xuhongjia pushed a commit to Deckers-Ohana/eventmesh that referenced this pull request Mar 13, 2025
…e code. (apache#4791)

* [ISSUE apache#3830] InterruptedExceptions should not be ignored in the code.

* [ISSUE apache#3830] fix code style

* [ISSUE apache#3830] delete Unneeded throw

* [ISSUE apache#3830] rethrown InterruptedException

* [ISSUE apache#3830] InterruptedException return new SendResult

---------

Co-authored-by: JiangShuJu <[email protected]>
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.

[Enhancement] InterruptedExceptions should not be ignored in the code.[ProducerImpl]
4 participants