-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
RegexPathSpec documentation and MatchedPath improvements #8163
Conversation
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
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.
I think you have well captured the current behaviour, but I think we should consider changing it a little as per my comment.
jetty-http/src/main/java/org/eclipse/jetty/http/pathmap/RegexPathSpec.java
Outdated
Show resolved
Hide resolved
+ Allow override of split index determination Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
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.
I think the logic is getting a bit complex and a bit burried. I've made a suggestion for how the description should be, but I think the following algorithm should be used as it is a bit more efficient with less name lookups:
switch(matcher.groupCount())
{
case 0: match=path; info=null;
break;
case 1:
if ("name".equals(group(1).name)
match=group; info=path.substring(group.end);
else
match=path.substring(0,group.start); info=group;
break;
default:
if (group("name").exists)
{
match=group("name");
info=group("info");
else
info=path.substring(group("name").end);
}
else if (group("info").exists)
match=path.substring(0,group.start); info=group; break;
else
match=path; info=null;
break;
}
jetty-http/src/main/java/org/eclipse/jetty/http/pathmap/RegexPathSpec.java
Outdated
Show resolved
Hide resolved
jetty-http/src/main/java/org/eclipse/jetty/http/pathmap/RegexPathSpec.java
Outdated
Show resolved
Hide resolved
jetty-http/src/main/java/org/eclipse/jetty/http/pathmap/RegexPathSpec.java
Outdated
Show resolved
Hide resolved
+ Cleanup testcase for MatchedPath + Test cases are now failing, need to rework algorithm. Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
@gregw I implemented your algorithm, but it makes quite the mess. (lots of test failures) The test argument order is ... Do you think these are sane expectations? |
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
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.
I think this is good enough for now, but with TODOs for future optimizations.
{ | ||
if (idxNameStart >= 0) | ||
// we know we are splitting | ||
int idxNameEnd = endOf(matcher, "name"); |
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.
Ultimately this lookup makes me itch! If they are not using the named group, then an exception is created and ignored for every lookup attempt.
For now, can we add a TODO that when we scan the pattern, we should look for the presence of "" and only do this lookup if we have seen it in the pattern.
String gName = valueOf(matcher, "name"); | ||
String gInfo = valueOf(matcher, "info"); |
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.
Two exceptions may be created and ignored here. So again, I think we need a TODO to optimise that away in future.
Once the javadoc issues on PR #8173 are green and merged, this should build green, then I can merge this one. |
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Added javadoc, and improved RegexMatchedPath behavior with more unit tests.
Signed-off-by: Joakim Erdfelt joakim.erdfelt@gmail.com