Forward compatibility with Jetty 10 in JenkinsRule
#455
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Required for jenkinsci/jenkins#6805, #453, jenkinsci/jenkins#6802.
Problem
When the application is started from
java -jar jenkins.war
,hudson.WebAppMain
runs to initialize the application. In the context of the test harness, we do not want this to happen, since the test harness initializes Jenkins itself.The current method does this with a call to
context.setEventListeners(null)
inNoListenerConfiguration
. This has three problems:final
, forcing the need for copypasta in https://github.com/jenkinsci/jenkins/blob/6de288f424f3a76d9fab9e54e379ca171b08e158/test/src/test/java/hudson/util/BootFailureTest.java#L79-L80=.JenkinsRuleTest
.hudson.WebAppMain
, which is its purpose, but it also clears all other listeners, including other valuable cleanup listeners. The current (ordered) list of listeners in Jetty 9 is:org.eclipse.jetty.servlet.listener.ELContextCleaner
org.eclipse.jetty.servlet.listener.IntrospectorCleaner
jenkins.util.SystemProperties.Listener
hudson.WebAppMain
(needs to be cleared in the test harness)jenkins.JenkinsHttpSessionListener
Solution
We make the class non-
final
and remove only theWebAppMain
listener. This fixes all three problems:JenkinsRuleTest
starts working in Jetty 10.org.eclipse.jetty.websocket.core.server.WebSocketServerComponentsCleanupListener
org.eclipse.jetty.websocket.server.JettyWebSocketServerContainer
org.eclipse.jetty.websocket.server.JettyWebSocketServerContainerCleanupListener
org.eclipse.jetty.servlet.listener.ELContextCleaner
org.eclipse.jetty.servlet.listener.IntrospectorCleaner
jenkins.util.SystemProperties.Listener
hudson.WebAppMain
(needs to be cleared in the test harness)jenkins.JenkinsHttpSessionListener
org.eclipse.jetty.server.AllowedResourceAliasChecker.AllowedResourceAliasCheckListener
Testing done
I tested this with
BootFailureTest
in core with both Jetty 9 (jenkinsci/jenkins#6805) and Jetty 10 (jenkinsci/jenkins#6802).