This repository has been archived by the owner on Jan 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 137
[improvement] Remove expensive useless String.format() in canConsumeAsync #1893
Merged
Demogorgon314
merged 4 commits into
streamnative:master
from
gaoran10:remove-expensive-usage-in-can-consume
Jun 30, 2023
Merged
[improvement] Remove expensive useless String.format() in canConsumeAsync #1893
Demogorgon314
merged 4 commits into
streamnative:master
from
gaoran10:remove-expensive-usage-in-can-consume
Jun 30, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(cherry picked from commit fa63a4a)
gaoran10
changed the title
Remove expensive useless String.format() in canConsumeAsync
[improvement] Remove expensive useless String.format() in canConsumeAsync
Jun 8, 2023
Codecov Report
@@ Coverage Diff @@
## master #1893 +/- ##
============================================
- Coverage 18.77% 18.33% -0.44%
Complexity 743 743
============================================
Files 184 190 +6
Lines 13289 13601 +312
Branches 1211 1260 +49
============================================
- Hits 2495 2494 -1
- Misses 10613 10926 +313
Partials 181 181
|
@@ -166,8 +166,7 @@ public CompletableFuture<Boolean> canProduceAsync(KafkaPrincipal principal, Reso | |||
|
|||
@Override | |||
public CompletableFuture<Boolean> canConsumeAsync(KafkaPrincipal principal, Resource resource) { | |||
checkArgument(resource.getResourceType() == ResourceType.TOPIC, | |||
String.format("Expected resource type is TOPIC, but have [%s]", resource.getResourceType())); | |||
checkArgument(resource.getResourceType() == ResourceType.TOPIC); |
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.
Can we extract a method like this: private void checkArgument(ResourceType expected, ResourceType actual)
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.
And we can print the error message in the checkArgument
method when the type is unequal.
Demogorgon314
previously approved these changes
Jun 26, 2023
Demogorgon314
approved these changes
Jun 30, 2023
BewareMyPower
pushed a commit
that referenced
this pull request
Jul 3, 2023
…sync (#1893) (cherry picked from commit fa63a4a) This PR is used to cherry-pick the commit datastax/starlight-for-kafka@fa63a4a. ### Motivation The String.format() is an expensive operation in the method canConsumeAsync. ### Modifications Remove the String.format() operation. Co-authored-by: Enrico Olivelli <[email protected]> (cherry picked from commit 45bd29c)
Demogorgon314
pushed a commit
that referenced
this pull request
Jul 5, 2023
…sync (#1893) (cherry picked from commit fa63a4a) This PR is used to cherry-pick the commit datastax/starlight-for-kafka@fa63a4a. ### Motivation The String.format() is an expensive operation in the method canConsumeAsync. ### Modifications Remove the String.format() operation. Co-authored-by: Enrico Olivelli <[email protected]> (cherry picked from commit 45bd29c)
BewareMyPower
pushed a commit
that referenced
this pull request
Jul 17, 2023
…sync (#1893) (cherry picked from commit fa63a4a) This PR is used to cherry-pick the commit datastax/starlight-for-kafka@fa63a4a. ### Motivation The String.format() is an expensive operation in the method canConsumeAsync. ### Modifications Remove the String.format() operation. Co-authored-by: Enrico Olivelli <[email protected]> (cherry picked from commit 45bd29c)
Demogorgon314
pushed a commit
to Demogorgon314/kop
that referenced
this pull request
Aug 14, 2023
…sync (streamnative#1893) (cherry picked from commit fa63a4a) This PR is used to cherry-pick the commit datastax/starlight-for-kafka@fa63a4a. ### Motivation The String.format() is an expensive operation in the method canConsumeAsync. ### Modifications Remove the String.format() operation. Co-authored-by: Enrico Olivelli <[email protected]> (cherry picked from commit 45bd29c) Fix conflicts by applying `checkResourceType` to `canDeleteGroupAsync`.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
cherry-picked/branch-2.11
cherry-picked/branch-3.0
no-need-doc
This pr does not need any document
release/2.10.4
release/2.11
release/3.0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(cherry picked from commit fa63a4a)
This PR is used to cherry-pick the commit datastax/starlight-for-kafka@fa63a4a.
Motivation
The String.format() is an expensive operation in the method canConsumeAsync.
Modifications
Remove the String.format() operation.
Documentation
Check the box below.
Need to update docs?
doc-required
(If you need help on updating docs, create a doc issue)
no-need-doc
(Please explain why)
doc
(If this PR contains doc changes)