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

Carry the triggered rule in subclasses of BlockException #469

Merged
merged 2 commits into from
Jan 31, 2019

Conversation

sczyh30
Copy link
Member

@sczyh30 sczyh30 commented Jan 28, 2019

Describe what this PR does / why we need it

Carry the triggered rule in subclasses of BlockException. See #424 for more information.

Does this pull request fix one issue?

Resolves #424

Describe how you did it

Refactor each subclass of BlockException and add a rule field to carry the triggered rule (except the SystemRule). Users can get the trigger rule from the getRule() method.

Describe how to verify it

It's a compatible change. The CI should pass.

Special notes for reviews

NONE

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
@sczyh30 sczyh30 added the to-review To review label Jan 28, 2019
Copy link
Contributor

@CarpenterLee CarpenterLee left a comment

Choose a reason for hiding this comment

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

It seems that moving getRule () method into BlockException is more appropriate.

…lasses

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
Copy link
Contributor

@CarpenterLee CarpenterLee left a comment

Choose a reason for hiding this comment

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

LGTM

@sczyh30
Copy link
Member Author

sczyh30 commented Jan 31, 2019

Due to the fact that JLS does not allow generic subclasses of Throwable, I've added the rule field and getRule method in BlockException (rule type as AbstractRule). But in subclasses of BlockException we can ensure the type of the rule in the constructor, so we can override the getRule method and cast it to actual rule type.

@codecov-io
Copy link

codecov-io commented Jan 31, 2019

Codecov Report

Merging #469 into master will increase coverage by 1.6%.
The diff coverage is 50%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master     #469     +/-   ##
===========================================
+ Coverage     37.65%   39.25%   +1.6%     
- Complexity      984     1077     +93     
===========================================
  Files           235      236      +1     
  Lines          7434     7713    +279     
  Branches       1018     1085     +67     
===========================================
+ Hits           2799     3028    +229     
- Misses         4274     4294     +20     
- Partials        361      391     +30
Impacted Files Coverage Δ Complexity Δ
...ntinel/slots/block/degrade/DegradeRuleManager.java 26.38% <0%> (ø) 7 <0> (ø) ⬇️
...sentinel/slots/block/degrade/DegradeException.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...sp/sentinel/slots/system/SystemBlockException.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...sentinel/slots/block/flow/param/ParamFlowSlot.java 76.78% <100%> (ø) 18 <0> (ø) ⬇️
...libaba/csp/sentinel/slots/block/flow/FlowSlot.java 100% <100%> (ø) 8 <0> (ø) ⬇️
.../sentinel/slots/block/authority/AuthoritySlot.java 88.23% <100%> (ø) 7 <0> (ø) ⬇️
...ibaba/csp/sentinel/slots/block/BlockException.java 54.28% <44.44%> (+15.82%) 8 <1> (+4) ⬆️
...nel/slots/block/flow/param/ParamFlowException.java 42.85% <57.14%> (-19.65%) 3 <1> (ø)
...inel/slots/block/authority/AuthorityException.java 30% <66.66%> (-12.86%) 2 <1> (ø)
...a/csp/sentinel/slots/block/flow/FlowException.java 50% <66.66%> (+7.14%) 3 <1> (+1) ⬆️
... and 20 more

Continue to review full report at Codecov.

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

@sczyh30 sczyh30 merged commit 412e1ec into master Jan 31, 2019
@sczyh30 sczyh30 removed the to-review To review label Jan 31, 2019
@sczyh30 sczyh30 deleted the enhancement/block-exception-more-info branch February 19, 2019 08:26
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.

More information (e.g. triggered rules, real-time QPS) is needed to carry in BlockException
3 participants