TracePathMatcher should match pattern "**" with paths end by "/" (#7875)#72
TracePathMatcher should match pattern "**" with paths end by "/" (#7875)#72newboy2004 wants to merge 8 commits intoapache:mainfrom
Conversation
|
If you want to add this, you need to enhance the existing one, rather than use Spring to replace. |
|
@devkanro Could you recheck this? I think you wrote this originally. |
|
ok |
| // End of pattern, just check the end of string is '/' quickly. | ||
| if (p >= pat.length() && s < str.length()) { | ||
| return str.charAt(str.length() - 1) != '/'; | ||
| return true; | ||
| } |
There was a problem hiding this comment.
Maybe the comment need be changed.
// End of pattern, make matching success quickly.
if (p >= pat.length() && s < str.length()) {
return true;
}There was a problem hiding this comment.
In my originally design, the /eureka/** not match the /eureka/client/ is a feature, but I have no preference for this, I can accept it regardless of whether it matches or does not match.
Could you show your use cases and benefits for it?
There was a problem hiding this comment.
I think because some users think all things under /eureka/ belong to this match rule.
There was a problem hiding this comment.
@devkanro Could you share a little more about why /eureka/client/ doesn't belong to /eureka/**? I hope we could have a fully evaluation considering this was being asked more than once.(This is the first fix)
There was a problem hiding this comment.
Ummm...I can't remember what I thought at the time...
Maybe it's because /eureka/ doesn't match /eureka, I want to make it same as /eureka/** case?
I have changed my mind, the /eureka/client/ should belong to /eureka/**.
LGTM
There was a problem hiding this comment.
And maybe the rule of wildcardMatch also should be changed?
Should /eureka/* match with /eureka/client/ ?
There was a problem hiding this comment.
/eureka/ doesn't match /eureka
I think they should be same, do you know any different in some use cases?
I feel they are same.
And maybe the rule of wildcardMatch also should be changed?
Should /eureka/* match with /eureka/client/ ?
Yes, it should be supported, too.
There was a problem hiding this comment.
The current resolution is, what your proposal is correct. Just follow the polish requirements.
There was a problem hiding this comment.
/eureka/ doesn't match /eureka
Ummm, The reason I do this is to simplify the state machine. There are no other special considerations.
|
@newboy2004 Please follow the @devkanro 's comments to polish/enhance this fix and update the changes.md in the root. |
ok,i continue repair it. By the way, accessing githubcom is slow. Is there any good solution? |
|
The simple resolution is remove the last '/' for the pattern and string. If this change is done during the matching process, many states will be introduced, which will complicate the state machine of the matcher. I think it is a good choice to normalize(remove the last '/') the pattern and value before entering the matcher. |
|
Agree, this kind of change seems better and easier to understand. |
Continue to repair * matching, and remove the last / of pattern and string before? |
|
Remove / before the match, I think. Then no need to change matching core, fromy understanding. |
please see blow origin code: i think remove / after,Assert should return true. |
Yes, |
i wait for final opinion? my local code repo have already finish what * rule match and unit test according before discussion waiting for you final opionion |
|
I think the conclusion is very clear. The recommended way to fix is removing the last |
ok,i understand. |
| char pc = safeCharAt(pat, p); | ||
| //if pat already arrival end,and str in position of s is not '/',then return true | ||
| if (pc == '\u0000' && safeCharAt(str, s) != '/') { | ||
| return true; |
There was a problem hiding this comment.
I think this change will cause a bug that 'abc/*' matching 'abc/foo/bar'
| // End of pattern, just check the end of string is '/' quickly. | ||
| if (p >= pat.length() && s < str.length()) { | ||
| return str.charAt(str.length() - 1) != '/'; | ||
| return true; |
There was a problem hiding this comment.
I think we can remove this check after we remove the last '/' both of pattern and value,
I think the current doesn't follow this conclusion. We just need to slightly change the input. |
ok,but if i remove the last '/' in the operation name,please confirm blow code,return true or false: i think '' match zero or one char,but remove the last '/' after,pattern='/eureka/' path='/eureka',accroding Ant Rule,result should return false,do you think? |
|
OK, I can see this becomes a tricky point. From this point of view, removing I think we should consider whether changing plugin's operation rules fits more cases. |
We can consider not supporting this so-called bug,so I'll consider claiming other tasks?haha |
|
All operation names, such as typically |
The code test mentioned above should return false,please @devkanro check |
The point here is, |
so remvoing the last '/' suffix, it's not a good idea, it breaks the expectation. |
|
Removing suffix is not a good idea. And changing logic makes me concerns about new bugs. |
|
We should rearrange the rules so that we can analyze the edge conditions. Basic (from spring ant matcher):
Edge(for *):
Edge(for **):
Edge(for normal):
|
|
My answer(all false for current behavior): Edge(for *):
Edge(for **):
Edge(for normal):
|
|
No update in 2 weeks. |
Fix <TracePathMatcher should match pattern "**" with paths end by "/">