[JENKINS-68933] Better WebSocket testing, removal of reflection - #6780
Conversation
|
Looking over jetty/jetty.project#6623 & jetty/jetty.project#3544 & jetty/jetty.project#5874. Does not look like this will be straightforward—the APIs have changed substantially, and until |
could we just move it across? and maintain a backport line for fixes that are substantial enough? |
|
Perhaps. First I want to try to get it to work on 10, and then I can look into making it still work on 9. |
|
Rebased the test on top of the parent of #6694, where it passed. |
|
Tests appear to fail here because the build is running PR-merge strategy. @timja @dduportal I thought we had decided to switch builds of this repo to use PR-head strategy? Maybe it was only |
only bom was switched |
|
Split off #6785 to attempt (so far without success) to use this framework to support Jetty 10. |
basil
left a comment
There was a problem hiding this comment.
Thanks Jesse, I had started working on a similar PR earlier today but you obviously got it done a lot faster. In the interest of saving time I took the liberty of pushing a few commits to your branch to fix static analysis issues. I also left a comment in #6785 (comment) explaining how to get this to work with Jetty 10.
|
Well now there's a a |
| <spotbugs.effort>Max</spotbugs.effort> | ||
| <spotbugs.threshold>Medium</spotbugs.threshold> | ||
| <spotbugs.excludeFilterFile>${project.basedir}/../src/spotbugs/spotbugs-excludes.xml</spotbugs.excludeFilterFile> | ||
| <spotbugs.excludeFilterFile>${maven.multiModuleProjectDirectory}/src/spotbugs/spotbugs-excludes.xml</spotbugs.excludeFilterFile> |
Well, there is no rush on this one since it does not fix anything for users, it is just making it easier to work on this code.
Thanks! I will check the Javadoc issue. |
| <artifactId>maven-javadoc-plugin</artifactId> | ||
| <configuration> | ||
| <skip>true</skip> |
There was a problem hiding this comment.
Note that this should probably also be done in the cli and war modules.
| }; | ||
| } | ||
|
|
||
| private static Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp) { |
There was a problem hiding this comment.
Note the Object in the signature. Javadoc is super helpful
a websocket object to use
It is more or less through trial and error that I concluded (in #4369) that a WebSocketListener is expected; “normal usage” apparently means adding annotations to POJOs and just remembering what method signatures to use. I think this misconceived style is inherited from the javax.websocket API. (Which tries to make you declare WS-aware endpoints with more annotations, and fails to provide a simple Java API call to upgrade a connection, forcing us to rely on Jetty-specific APIs.)
Otherwise closing connections sometimes produces stack traces ``` WARNING j.websocket.WebSocketSession#error: unhandled WebSocket service error java.nio.channels.ClosedChannelException at org.eclipse.jetty.websocket.core.internal.WebSocketSessionState.onEof(WebSocketSessionState.java:169) at org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession.onEof(WebSocketCoreSession.java:253) at org.eclipse.jetty.websocket.core.internal.WebSocketConnection.fillAndParse(WebSocketConnection.java:482) at org.eclipse.jetty.websocket.core.internal.WebSocketConnection.onFillable(WebSocketConnection.java:340) at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:319) at … ``` or ``` WARNING j.agents.WebSocketAgents$Session#error java.nio.channels.ClosedChannelException at org.eclipse.jetty.websocket.core.internal.WebSocketSessionState.onEof(WebSocketSessionState.java:169) at org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession.onEof(WebSocketCoreSession.java:253) at … ``` though I am not sure if that is actually new behavior.
|
This PR is now ready for merge. We will merge it after approximately 24 hours if there is no negative feedback. Please see the merge process documentation for more information about the merge process. Thanks! |
| </dependency> | ||
| <dependency> | ||
| <groupId>org.kohsuke.metainf-services</groupId> | ||
| <artifactId>metainf-services</artifactId> |
There was a problem hiding this comment.
Note that this will cause that library to be managed for plugin POMs (like credentials or artifact-manager-s3) for the first time. Seems like a good thing; I am not sure why it was not already in the core BOM. But if this is a problem for any reason, it could trivially be reverted, and the version fixed in the new module.
There was a problem hiding this comment.
Yeah, I don't see a problem with including it in the core BOM. This PR does also start shipping WEB-INF/lib/metainf-services-1.9.jar, which seems harmless, but I'm not entirely sure it's necessary either, since it seems to be more of a compile-time thing. No request for change or action item here, just noting the additional JAR.
There was a problem hiding this comment.
FWIW there is an exclusion for this library elsewhere in the build: https://github.com/jenkinsci/jenkins/blob/644a261e78e9d80e2442787c8418cbdf283ac7e1/war/pom.xml#L92-L96=
| <dependency> | ||
| <groupId>javax.servlet</groupId> | ||
| <artifactId>javax.servlet-api</artifactId> | ||
| <version>3.1.0</version> |
There was a problem hiding this comment.
Deliberately not using BOM version here.
There was a problem hiding this comment.
Yeah, I saw that and I agree with using 3.1.0 because that is the lowest common denominator for Jetty 9 and Jetty 10. But the downside is this is adding the JAR to WEB-INF/lib/javax.servlet-api-3.1.0.jar in the WAR, which I think is undesirable because it is not actually used at runtime; rather, Winstone's copy is used. So to fix this I think we should exclude it when we pull in websocket-spi in core/pom.xml, which already has a provided dependency on servlet-api that is aligned with Jetty's.
olamy
left a comment
There was a problem hiding this comment.
oh yes Jetty 10 API for websocket has changed a lot (it's supposed to be more easy to use but still a big change...)
good work here! (Hopefully we will not have to keep this jetty9 too long?)
| private static final String ATTR_LISTENER = Jetty9Provider.class.getName() + ".listener"; | ||
|
|
||
| // TODO does not seem possible to use HttpServletRequest.get/setAttribute for this | ||
| private static final Map<Listener, Session> sessions = new WeakHashMap<>(); |
See JENKINS-68933 and #6694 (comment). Amending #4369.
Proposed changelog entries
Maintainer checklist
Before the changes are marked as
ready-for-merge:Proposed changelog entriesare accurate, human-readable, and in the imperative moodupgrade-guide-neededlabel is set and there is aProposed upgrade guidelinessection in the PR title. (example)lts-candidateto be considered (see query).