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

Issue #10661 Allow jetty api to override servlets and mappings from webdefault #10668

Merged
merged 14 commits into from
Oct 19, 2023

Conversation

janbartel
Copy link
Contributor

Closes #10661

@janbartel janbartel self-assigned this Oct 4, 2023
@janbartel janbartel requested a review from gregw October 4, 2023 22:08
Copy link
Contributor

@joakime joakime left a comment

Choose a reason for hiding this comment

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

One test case assertion seems incomplete, and then some odd indenting.
Nothing that would hold up this PR IMO, but it should be addressed.

@janbartel janbartel requested a review from joakime October 6, 2023 00:01
assertEquals(null, mapping);
mapping = m;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

So you iterate through all of the mappings, what if there are 2 mappings both with path spec /? (I know this shouldn't be possible, but you found we accidentally did just that before this PR, and we should ensure that we don't have that regression again)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Line 147 is doing exactly this.

Copy link
Contributor

@joakime joakime left a comment

Choose a reason for hiding this comment

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

Check for duplicate mapping

@janbartel janbartel requested a review from joakime October 6, 2023 05:24
@@ -1054,34 +1063,41 @@ public ServletMapping addServletMapping(String servletName, XmlParser.Node node,
{
//The same path has been mapped multiple times, either to a different servlet or the same servlet.
//If its a different servlet, this is only valid to do if the old mapping was from a default descriptor.
Copy link
Contributor

Choose a reason for hiding this comment

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

If it is valid to change a mapping from a default descriptor... and we allow embedded code to be used instead of a default descriptor, then why isn't it valid to do if the old mapping was from embedded?
I.e. If we define a servlet in embedded it is seen as a default, but a mapping appears to be handled differently?

Not sure exactly what should be done here... but either way probably need to comment to exact reasoning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we allow descriptors to override embedded, then a user can never change a mapping that came from the default descriptor. The principle of least surprise says to me that if I define a servlet and mapping in embedded, I would expect those to be honoured, and not obscured by something from the defaults descriptor, which is mostly hidden from users buried inside jetty-webapp jar.

Copy link
Contributor

Choose a reason for hiding this comment

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

@agree I think we agree on the action, but disagree on the description. If either a servlet or a mapping is defined by embedded code, then it should not be overridden by the default descriptor, but could be overridden by a normal descriptor.

Said another way, the default for either Servlet or Mapping comes from either embedded or if not set there, then the webdefaults xml. Either default can be overridden by a normal descriptor.
So what I'd like to see is the same logic here as is done for a servlet. If the mapping is already defined and we are the default descriptor and the mapping came from embedded, then skip the current mapping.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does the latest commit make this any clearer?

@janbartel janbartel requested a review from gregw October 10, 2023 04:05
Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

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

Sorry, it is better... but I think it just reveals more questions about what we are doing in the first place. I don't understand why servlets are so simple and this is so complex.

I think we are going to need to collaborate on a solution.

Copy link
Contributor Author

@janbartel janbartel left a comment

Choose a reason for hiding this comment

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

I'm happy with your latest changes @gregw so if you can give this a +1 I'll get it committed.

gregw
gregw previously approved these changes Oct 11, 2023
joakime
joakime previously approved these changes Oct 16, 2023
@janbartel janbartel dismissed stale reviews from joakime and gregw via 965ebdd October 19, 2023 03:24
@janbartel janbartel requested a review from gregw October 19, 2023 04:21
@janbartel janbartel merged commit 14a5ba3 into jetty-12.0.x Oct 19, 2023
2 checks passed
@janbartel janbartel deleted the jetty-12.0.x-10661-jetty-api-webdefaults branch October 19, 2023 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Ensure jetty api servlets/filters take precedence over webdefault.xml declarations.
3 participants