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

Upgrade Jetty from 9.4.49.v20220914 to 10.0.12 #409

Merged
merged 1 commit into from Dec 8, 2022

Conversation

basil
Copy link
Member

@basil basil commented Dec 7, 2022

Now that the HPI plugin requires Java 11, we can move to a Jetty 10 based implementation To test this I ran mvn hpi:run before and after this change, ensuring that Jenkins came up successfully in both cases and could be reloaded by pressing the enter key.

@basil basil added dependencies Pull requests that update a dependency file java Pull requests that update Java code labels Dec 7, 2022
@@ -1,15 +1,16 @@
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

---
Copy link
Member Author

Choose a reason for hiding this comment

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

Making yamllint(1) happy.

Copy link
Member

Choose a reason for hiding this comment

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

Or just delete the comment since the link is dead anyway!

Copy link
Member Author

Choose a reason for hiding this comment

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

Pre-existing issue

Comment on lines -39 to -45

## Updating Jetty
`hpi:run` mojo is a variant of `jetty:run` mojo, and because of the way plugin descriptor is generated, this module copies some code from Jetty Maven plugin, specifically `AbstractJettyMojo.java` and `ConsoleScanner.java`.

To keep upstream tracking easier, pristine copies of these files are copied into `incoming-x.y` branch, then package renamed. This version specific incoming branch is then "theirs" merged into the `incoming` branch, which acts as the upstream tracking branch.

This branch is then merged into `master` via `git merge -X ignore-space-at-eol incoming`. See diff between `incoming` and `master` on these files to see the exact local patches.
Copy link
Member Author

Choose a reason for hiding this comment

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

No longer relevant, as we no longer copy code from Jetty Maven plugin.

Comment on lines +164 to +169
<exclusions>
<exclusion>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
</exclusions>
Copy link
Member Author

Choose a reason for hiding this comment

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

Was pulling in an ancient version of ASM 3, which is not compatible with Jetty Maven plugin.

Comment on lines +211 to +216
<exclusions>
<exclusion>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
</exclusion>
</exclusions>
Copy link
Member Author

Choose a reason for hiding this comment

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

Was pulling in a Jakarta import version of this API which conflicts with that of Jetty.

<exclude>org.codehaus.plexus:plexus-archiver</exclude>
<exclude>org.codehaus.plexus:plexus-container-default</exclude>
<exclude>org.ow2.asm:asm</exclude>
Copy link
Member Author

Choose a reason for hiding this comment

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

Miscellaneous cleanup: realized that this was unnecessary while updating this list.

getWebAppConfig().setWar(webAppFile.getCanonicalPath());
super.configureWebApp();
Copy link
Member Author

Choose a reason for hiding this comment

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

This has to be done after setting the WAR rather than before in order to avoid tripping an assertion.

@@ -540,6 +534,7 @@ public void configureWebApplication() throws Exception {
userStore.addUser("bob", new Password("bob"), new String[] {"user", "male"});
userStore.addUser("charlie", new Password("charlie"), new String[] {"user", "male"});
getWebAppConfig().getSecurityHandler().setLoginService(hashLoginService);
finishConfigurationBeforeStart();
Copy link
Member Author

Choose a reason for hiding this comment

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

The super class no longer provides two distinct hooks here, but to keep the diff small I retained the existing split between two methods and made the first vector into the second.

@@ -605,93 +600,30 @@ private String loadVersion(InputStream is) throws IOException {
}

@Override
public void configureScanner() throws MojoExecutionException {
public void startScanner() throws Exception {
Copy link
Member Author

Choose a reason for hiding this comment

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

Adapting the hack to changes in the superclass's calling conventions. See the comment for explanation.

// Use a bigger buffer, as Stapler traces can get pretty large on deeply nested URLs.
hc.setResponseHeaderSize(12 * 1024);

super.startScanner();
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Was copypasta from the superclass with no customizations, except for the call to generateHpl() which was dead code anyway.

Comment on lines +617 to 624
protected boolean isPackagingSupported() {
if (!supportedPackagings.contains("hpi")) {
List<String> newSupportedPackagings = new ArrayList<>(supportedPackagings);
newSupportedPackagings.add("hpi");
supportedPackagings = List.copyOf(newSupportedPackagings);
}
return super.isPackagingSupported();
}
Copy link
Member Author

Choose a reason for hiding this comment

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

I considered forcing consumers to add

              <supportedPackagings>
                <supportedPackaging>hpi</supportedPackaging>
              </supportedPackagings>

but felt it would be smoother if the default included hpi. I didn't remove war but I don't feel strongly about this.

Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

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

Thanks!

@@ -1,15 +1,16 @@
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

---
Copy link
Member

Choose a reason for hiding this comment

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

Or just delete the comment since the link is dead anyway!

Comment on lines +166 to 167
@Parameter(property = "port", defaultValue = "8080")
protected int defaultPort;
Copy link
Member

Choose a reason for hiding this comment

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

I think we would prefer to keep the static port anyway, since this is for interactive use and having a stable root URL across runs is desirable.

@basil basil merged commit 5597da8 into jenkinsci:master Dec 8, 2022
@basil basil deleted the jetty10 branch December 8, 2022 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file java Pull requests that update Java code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants