-
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
Issue #10661 Allow jetty api to override servlets and mappings from webdefault #10668
Issue #10661 Allow jetty api to override servlets and mappings from webdefault #10668
Conversation
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.
One test case assertion seems incomplete, and then some odd indenting.
Nothing that would hold up this PR IMO, but it should be addressed.
...ee10-webapp/src/test/java/org/eclipse/jetty/ee10/webapp/StandardDescriptorProcessorTest.java
Outdated
Show resolved
Hide resolved
jetty-ee10/jetty-ee10-webapp/src/test/resources/web-redefine-mapping-fail.xml
Outdated
Show resolved
Hide resolved
jetty-ee10/jetty-ee10-webapp/src/test/resources/web-redefine-mapping.xml
Outdated
Show resolved
Hide resolved
...y-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/StandardDescriptorProcessorTest.java
Outdated
Show resolved
Hide resolved
jetty-ee9/jetty-ee9-webapp/src/test/resources/web-redefine-mapping-fail.xml
Outdated
Show resolved
Hide resolved
jetty-ee9/jetty-ee9-webapp/src/test/resources/web-redefine-mapping.xml
Outdated
Show resolved
Hide resolved
…10661-jetty-api-webdefaults
assertEquals(null, mapping); | ||
mapping = m; | ||
} | ||
} |
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.
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)
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.
Line 147 is doing exactly this.
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.
Check for duplicate mapping
...y-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/StandardDescriptorProcessorTest.java
Show resolved
Hide resolved
...ee10-webapp/src/test/java/org/eclipse/jetty/ee10/webapp/StandardDescriptorProcessorTest.java
Show resolved
Hide resolved
...ee10-webapp/src/test/java/org/eclipse/jetty/ee10/webapp/StandardDescriptorProcessorTest.java
Show resolved
Hide resolved
...tty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/StandardDescriptorProcessor.java
Outdated
Show resolved
Hide resolved
@@ -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. |
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.
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.
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.
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.
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.
@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.
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.
Does the latest commit make this any clearer?
…10661-jetty-api-webdefaults
…e10/webapp/StandardDescriptorProcessor.java Co-authored-by: Greg Wilkins <gregw@webtide.com>
…10661-jetty-api-webdefaults
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.
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.
...tty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/StandardDescriptorProcessor.java
Outdated
Show resolved
Hide resolved
...tty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/StandardDescriptorProcessor.java
Show resolved
Hide resolved
...tty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/StandardDescriptorProcessor.java
Outdated
Show resolved
Hide resolved
...tty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/StandardDescriptorProcessor.java
Show resolved
Hide resolved
...tty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/StandardDescriptorProcessor.java
Outdated
Show resolved
Hide resolved
...tty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/StandardDescriptorProcessor.java
Outdated
Show resolved
Hide resolved
...tty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/StandardDescriptorProcessor.java
Outdated
Show resolved
Hide resolved
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'm happy with your latest changes @gregw so if you can give this a +1 I'll get it committed.
…10661-jetty-api-webdefaults
Closes #10661