You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "poorbarcode (via GitHub)" <gi...@apache.org> on 2024/07/09 02:58:07 UTC
[PR] [fix][broker]Fix lookupService.getTopicsUnderNamespace can not work with a quote pattern [pulsar]
poorbarcode opened a new pull request, #23014:
URL: https://github.com/apache/pulsar/pull/23014
### Motivation
**Background**
- `Pattern.quote` returns a literal pattern string for the specified
- The result of `Pattern.quote("123")` will be `\Q123\E`
**Issue**
So far, `TopicList.removeTopicDomainScheme` will remove `\Q` which is the prefix of the input string. It leads ` lookupService.getTopicsUnderNamespace` can not work with a quote pattern.
### Modifications
Fix the bug
### Documentation
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
- [ ] `doc` <!-- Your PR contains doc changes. -->
- [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
- [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `doc-complete` <!-- Docs have been already added -->
### Matching PR in forked repository
PR in forked repository: x
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][broker]Fix lookupService.getTopicsUnderNamespace can not work with a quote pattern [pulsar]
Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode merged PR #23014:
URL: https://github.com/apache/pulsar/pull/23014
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][broker]Fix lookupService.getTopicsUnderNamespace can not work with a quote pattern [pulsar]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #23014:
URL: https://github.com/apache/pulsar/pull/23014#issuecomment-2216487858
## [Codecov](https://app.codecov.io/gh/apache/pulsar/pull/23014?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 73.45%. Comparing base [(`bbc6224`)](https://app.codecov.io/gh/apache/pulsar/commit/bbc62245c5ddba1de4b1e7cee4ab49334bc36277?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`fb2009f`)](https://app.codecov.io/gh/apache/pulsar/commit/fb2009fec1cd7d6d5e924197cf53a4f8938837a1?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
> Report is 445 commits behind head on master.
<details><summary>Additional details and impacted files</summary>
[](https://app.codecov.io/gh/apache/pulsar/pull/23014?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## master #23014 +/- ##
============================================
- Coverage 73.57% 73.45% -0.13%
- Complexity 32624 33350 +726
============================================
Files 1877 1913 +36
Lines 139502 143390 +3888
Branches 15299 15639 +340
============================================
+ Hits 102638 105322 +2684
- Misses 28908 30031 +1123
- Partials 7956 8037 +81
```
| [Flag](https://app.codecov.io/gh/apache/pulsar/pull/23014/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [inttests](https://app.codecov.io/gh/apache/pulsar/pull/23014/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `27.84% <0.00%> (+3.26%)` | :arrow_up: |
| [systests](https://app.codecov.io/gh/apache/pulsar/pull/23014/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `24.73% <45.45%> (+0.41%)` | :arrow_up: |
| [unittests](https://app.codecov.io/gh/apache/pulsar/pull/23014/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `72.51% <100.00%> (-0.34%)` | :arrow_down: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Files](https://app.codecov.io/gh/apache/pulsar/pull/23014?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [...ava/org/apache/pulsar/common/topics/TopicList.java](https://app.codecov.io/gh/apache/pulsar/pull/23014?src=pr&el=tree&filepath=pulsar-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpulsar%2Fcommon%2Ftopics%2FTopicList.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NvbW1vbi90b3BpY3MvVG9waWNMaXN0LmphdmE=) | `97.22% <100.00%> (+7.56%)` | :arrow_up: |
... and [491 files with indirect coverage changes](https://app.codecov.io/gh/apache/pulsar/pull/23014/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][broker]Fix lookupService.getTopicsUnderNamespace can not work with a quote pattern [pulsar]
Posted by "gaoran10 (via GitHub)" <gi...@apache.org>.
gaoran10 commented on code in PR #23014:
URL: https://github.com/apache/pulsar/pull/23014#discussion_r1669605125
##########
pulsar-common/src/main/java/org/apache/pulsar/common/topics/TopicList.java:
##########
@@ -83,15 +85,23 @@ public static Set<String> minus(Collection<String> list1, Collection<String> lis
return s1;
}
- private static String removeTopicDomainScheme(String originalRegexp) {
+ @VisibleForTesting
+ static String removeTopicDomainScheme(String originalRegexp) {
if (!originalRegexp.toString().contains(SCHEME_SEPARATOR)) {
return originalRegexp;
}
- String removedTopicDomain = SCHEME_SEPARATOR_PATTERN.split(originalRegexp.toString())[1];
- if (originalRegexp.contains("^")) {
- return String.format("^%s", removedTopicDomain);
+ String[] parts = SCHEME_SEPARATOR_PATTERN.split(originalRegexp.toString());
+ String prefix = parts[0];
+ String removedTopicDomain = parts[1];
+ if (prefix.equals(TopicDomain.persistent.value()) || prefix.equals(TopicDomain.non_persistent.value())) {
+ prefix = "";
+ } else if (prefix.endsWith(TopicDomain.non_persistent.value())) {
+ prefix = prefix.substring(0, prefix.length() - TopicDomain.non_persistent.value().length());
+ } else if (prefix.endsWith(TopicDomain.persistent.value())){
+ prefix = prefix.substring(0, prefix.length() - TopicDomain.persistent.value().length());
Review Comment:
Do we have tests to cover this case?
##########
pulsar-common/src/main/java/org/apache/pulsar/common/topics/TopicList.java:
##########
@@ -83,15 +85,23 @@ public static Set<String> minus(Collection<String> list1, Collection<String> lis
return s1;
}
- private static String removeTopicDomainScheme(String originalRegexp) {
+ @VisibleForTesting
+ static String removeTopicDomainScheme(String originalRegexp) {
if (!originalRegexp.toString().contains(SCHEME_SEPARATOR)) {
return originalRegexp;
}
- String removedTopicDomain = SCHEME_SEPARATOR_PATTERN.split(originalRegexp.toString())[1];
- if (originalRegexp.contains("^")) {
- return String.format("^%s", removedTopicDomain);
+ String[] parts = SCHEME_SEPARATOR_PATTERN.split(originalRegexp.toString());
+ String prefix = parts[0];
+ String removedTopicDomain = parts[1];
+ if (prefix.equals(TopicDomain.persistent.value()) || prefix.equals(TopicDomain.non_persistent.value())) {
+ prefix = "";
+ } else if (prefix.endsWith(TopicDomain.non_persistent.value())) {
+ prefix = prefix.substring(0, prefix.length() - TopicDomain.non_persistent.value().length());
Review Comment:
Do we have tests to cover this case?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][broker]Fix lookupService.getTopicsUnderNamespace can not work with a quote pattern [pulsar]
Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode commented on code in PR #23014:
URL: https://github.com/apache/pulsar/pull/23014#discussion_r1669614786
##########
pulsar-common/src/main/java/org/apache/pulsar/common/topics/TopicList.java:
##########
@@ -83,15 +85,23 @@ public static Set<String> minus(Collection<String> list1, Collection<String> lis
return s1;
}
- private static String removeTopicDomainScheme(String originalRegexp) {
+ @VisibleForTesting
+ static String removeTopicDomainScheme(String originalRegexp) {
if (!originalRegexp.toString().contains(SCHEME_SEPARATOR)) {
return originalRegexp;
}
- String removedTopicDomain = SCHEME_SEPARATOR_PATTERN.split(originalRegexp.toString())[1];
- if (originalRegexp.contains("^")) {
- return String.format("^%s", removedTopicDomain);
+ String[] parts = SCHEME_SEPARATOR_PATTERN.split(originalRegexp.toString());
+ String prefix = parts[0];
+ String removedTopicDomain = parts[1];
+ if (prefix.equals(TopicDomain.persistent.value()) || prefix.equals(TopicDomain.non_persistent.value())) {
+ prefix = "";
+ } else if (prefix.endsWith(TopicDomain.non_persistent.value())) {
+ prefix = prefix.substring(0, prefix.length() - TopicDomain.non_persistent.value().length());
Review Comment:
Yes, see:
- https://github.com/apache/pulsar/pull/23014/files#diff-f68ba2fc789cf68f6cb7a9f588572d8743b98fd88b4fa72ac073855f551caeb8R1138-R1164
- https://github.com/apache/pulsar/pull/23014/files#diff-4104594a215409237c181ad71dede92abd0e4750b88d051fa5ba1327158f060dR114-R156
##########
pulsar-common/src/main/java/org/apache/pulsar/common/topics/TopicList.java:
##########
@@ -83,15 +85,23 @@ public static Set<String> minus(Collection<String> list1, Collection<String> lis
return s1;
}
- private static String removeTopicDomainScheme(String originalRegexp) {
+ @VisibleForTesting
+ static String removeTopicDomainScheme(String originalRegexp) {
if (!originalRegexp.toString().contains(SCHEME_SEPARATOR)) {
return originalRegexp;
}
- String removedTopicDomain = SCHEME_SEPARATOR_PATTERN.split(originalRegexp.toString())[1];
- if (originalRegexp.contains("^")) {
- return String.format("^%s", removedTopicDomain);
+ String[] parts = SCHEME_SEPARATOR_PATTERN.split(originalRegexp.toString());
+ String prefix = parts[0];
+ String removedTopicDomain = parts[1];
+ if (prefix.equals(TopicDomain.persistent.value()) || prefix.equals(TopicDomain.non_persistent.value())) {
+ prefix = "";
+ } else if (prefix.endsWith(TopicDomain.non_persistent.value())) {
+ prefix = prefix.substring(0, prefix.length() - TopicDomain.non_persistent.value().length());
+ } else if (prefix.endsWith(TopicDomain.persistent.value())){
+ prefix = prefix.substring(0, prefix.length() - TopicDomain.persistent.value().length());
Review Comment:
Yes, see:
- https://github.com/apache/pulsar/pull/23014/files#diff-f68ba2fc789cf68f6cb7a9f588572d8743b98fd88b4fa72ac073855f551caeb8R1138-R1164
- https://github.com/apache/pulsar/pull/23014/files#diff-4104594a215409237c181ad71dede92abd0e4750b88d051fa5ba1327158f060dR114-R156
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][broker]Fix lookupService.getTopicsUnderNamespace can not work with a quote pattern [pulsar]
Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode commented on PR #23014:
URL: https://github.com/apache/pulsar/pull/23014#issuecomment-2216325719
/pulsarbot rerun-failure-checks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org