-
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
Use Filter name to identify the WebSocketUpgradeFilter. #5648
Conversation
lachlan-roberts
commented
Nov 13, 2020
- Don't allow configuration of WebSocketMapping attribute.
- The WebSocketUpgradeFilter is identified by it's name, which must be set as the fully qualified class name.
Don't allow configuration of WebSocketMapping attribute. The WebSocketUpgradeFilter is identified by it's name, which must be set as the fully qualified class name. Signed-off-by: Lachlan Roberts <lachlan@webtide.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.
Where is the issue that caused this change?
How would a webapp have 2 WebSocketUpgradeFilters now?
How would they configure the second one?
I'm a big fat -1 on this change as it stands.
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
@joakime There was no issue put on github, it was from verbal conversations with Simone from the failures he got on cometd. I have pushed a test for the use of multiple |
jetty-websocket/websocket-javax-tests/src/test/resources/alt-filter-web.xml
Show resolved
Hide resolved
Signed-off-by: Lachlan Roberts <lachlan@webtide.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.
LGTM
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.
We need more test cases for alternate WSUF usage.
-
Two filters, both as WSUF.
one on default / dynamic at/*
(auto discovered mappings)
one on new url-pattern/alt/*
(programmatic mappings) -
Two filters, one overridden.
one on default / dynamic at/*
(auto discovered mappings)
one with overridden WSUF with custominit()
that configures the mappings. -
One filter, replacing default/dynamic filter.
one on/alt/*
, which is the filter to use for discovered mappings (for both javax.websocket and jetty apis)
For the programmatic mappings, this should support WebAppContext, configuring mappings via servlet initialization phase (eg: in a ServletContextListener. or ServletContainerInitializer)
This needs to be tested from a WebAppContext to ensure that there is sufficient API exposed to allow a WebApp to customize the mappings programmatically.
In Jetty 9.4.x this was a generic API at MappedWebSocketCreator.
But in Jetty 10.0.x this feature does not seem to be exposed in an API that a WebAppContext can use. (You have the various .addMapping methods on WebSocketServlet, but not with websockets that are managed by a WebSocketUpgradeFilter)
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
@joakime there is no distinction whether the mappings are auto-discovered or added programmatically. They both end up in the same We also do not currently allow mappings to be configured through the JettyWebSocketServerContainer container = JettyWebSocketServerContainer.getContainer(servletContext);
container.addMapping("/echo", EchoEndpoint.class); |
That's a problem. And a distinct difference from Jetty 9.4.x We need the ability to configure different mappings for different WSUFs.
That's also a problem for those that want to use WSUF with the Jetty WebSocket APIs. Not everyone wants to use the WebSocketServlet, as its incredibly limiting, and has undesired side effects related to filter execution. The dynamically added WebSocketUpgradeFilter is typically the first filter executed. (which many people actually want/like) But sometimes the user wants the WebSocketUpgradeFilter to execute after other filters (such as those for spring security). Also, the WebSocketMappings are far more powerful than the url-pattern from the servlet spec. We need to get all of these addressed. |
@joakime i don't understand the use case (s) you are describing. WebsocketMappings has no state other than the map it self a reference to the shared components like buffer pool. What does having multiple instances of WebsocketMappings do for an app? What can't it do? I think they can still have different configurations on the different filters and different mappings and still share the WebsocketMappings. |
Signed-off-by: Lachlan Roberts <lachlan@webtide.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 we should bake in the tests the following:
A) web.xml with non-WSUF filter => expect WSUF + non-WSUF
B) web.xml with non-WSUF and default WSUF in that order => expect non-WSUF + default WSUF
...socket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/JettyWebSocketWebApp.java
Show resolved
Hide resolved
jetty-websocket/websocket-jetty-tests/src/test/resources/wsuf-ordering2.xml
Show resolved
Hide resolved
...et-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/JettyWebSocketFilterTest.java
Show resolved
Hide resolved
Signed-off-by: Lachlan Roberts <lachlan@webtide.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.
There's some test failures left to address.
…WebSocketUpgradeFilter
Test failures seem unrelated, I have merged from 10.0.x to try to fix them. |