Skip to content

Fixes #16131 - Unpack overlays when META-INF already exists - #16208

Open
arimu1 wants to merge 1 commit into
jetty:jetty-12.1.xfrom
arimu1:fix/16131-overlay-meta-inf-exists
Open

arimu1 wants to merge 1 commit into
jetty:jetty-12.1.xfrom
arimu1:fix/16131-overlay-meta-inf-exists

Conversation

@arimu1

@arimu1 arimu1 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #16131

SelectiveJarResource.copyTo unpacks WAR overlays for jetty:run and jetty:start. Copying an entry such as META-INF/maven/.../pom.xml already creates META-INF. The manifest was then written with Files.createDirectory, which throws FileAlreadyExistsException when that directory exists. Jetty 9–11 used File.mkdir() for this step.

Files.createDirectories creates META-INF when it is missing, succeeds when it is already a directory, and throws FileAlreadyExistsException when that path is a file.

On jetty-12.1.x the class is jetty-core/jetty-maven/src/main/java/org/eclipse/jetty/maven/SelectiveJarResource.java. The ee9, ee10, and ee11 TestSelectiveJarResource classes call that shared class. The regression test is on the ee10 plugin, which is the module in the report.

Test

TestSelectiveJarResource.testCopyToWithManifestAndMavenDescriptor builds a JAR that contains MANIFEST.MF and META-INF/maven/com.example/demo/pom.xml, calls copyTo, and checks that both files exist.

Ran only that method on Temurin 21 against jetty-maven and its dependencies:

java -jar junit-platform-console-standalone-6.1.3.jar execute \
  --details=tree \
  --class-path <ee10 TestSelectiveJarResource classes>:<jetty-maven classes>:<jetty-maven test classpath> \
  --select-method org.eclipse.jetty.ee10.maven.plugin.TestSelectiveJarResource#testCopyToWithManifestAndMavenDescriptor(org.eclipse.jetty.toolchain.test.jupiter.WorkDir)

Before the fix: 1 test, 1 failure (FileAlreadyExistsException on META-INF from Files.createDirectory in SelectiveJarResource.copyTo).

After the fix: 1 test found, 1 successful, 0 failed, 0 skipped.

SelectiveJarResource.copyTo creates META-INF while copying entries such
as META-INF/maven/.../pom.xml, then wrote MANIFEST.MF with
Files.createDirectory. That throws FileAlreadyExistsException when the
directory already exists, so jetty:run and jetty:start fail on a WAR
overlay. Files.createDirectories succeeds when META-INF is a directory
and still fails when that path is a file.

Signed-off-by: arimu1 <19286898+arimu1@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

jetty-ee10-maven-plugin 12: jetty:run / jetty:start fail with FileAlreadyExistsException on META-INF when unpacking a WAR overlay

1 participant