Skip to content

Fix FileuploadToFileUpload2 package migration and milestone version - #1322

Merged
timtebeek merged 3 commits into
mainfrom
fix-fileupload2-package-migration
Oct 20, 2026
Merged

timtebeek merged 3 commits into
mainfrom
fix-fileupload2-package-migration

Conversation

@timtebeek

Copy link
Copy Markdown
Member

What's changed

FileuploadToFileUpload2 (part of JavaxMigrationToJakarta) swapped the dependency but never migrated any Java code, and one of its dependency swaps produced a version that doesn't exist. Follow-up to #1320.

1. Package moves never matched

All three ChangePackage steps used org.apache.commons.fileload… instead of org.apache.commons.fileupload…. The typo was on both the old and new side, and has been there since #819. That package never existed, so the steps were no-ops. Projects ended up on commons-fileupload2-jakarta-servlet5 with their imports still pointing at FileUpload 1.x.

  • org.apache.commons.fileupload.disk → org.apache.commons.fileupload2.core
  • org.apache.commons.fileupload.servlet → org.apache.commons.fileupload2.jakarta.servlet5
  • org.apache.commons.fileupload → org.apache.commons.fileupload2.core

The servlet classes were also renamed in FileUpload 2, so a package move alone would point at types that don't exist. These ChangeType steps now run before the package moves:

FileUpload 1.x FileUpload 2 (jakarta.servlet5)
servlet.ServletFileUpload JakartaServletFileUpload
servlet.ServletRequestContext JakartaServletRequestContext
servlet.FileCleanerCleanup JakartaFileCleaner

The display name and description had the same typo; both now describe what the recipe does, and recipes.csv is updated to match.

2. commons-fileupload2-jakarta swap produced a nonexistent version

The commons-fileupload2-jakarta → commons-fileupload2-jakarta-servlet5 swap had no newVersion, so it kept the old version. That artifact only ever had 2.0.0-M1, and servlet5 starts at 2.0.0-M2, so the result was commons-fileupload2-jakarta-servlet5:2.0.0-M1, which doesn't exist. It now sets newVersion: 2.0.0-M5, the same as the 1.x swap.

The milestone's classes have the same names as servlet5's but live in org.apache.commons.fileupload2.jakarta. A non-recursive ChangePackage now moves them to org.apache.commons.fileupload2.jakarta.servlet5.

Not covered

These changes put imports and type references in the right packages. Other FileUpload 2 API changes still need manual work: DiskFileItemFactory.builder(), the generic FileItem/JakartaServletFileUpload types, and renames such as FileItemStream → FileItemInput. Portlet support and org.apache.commons.fileupload.util have no direct equivalent in FileUpload 2.

Testing

FileuploadToFileUpload2Test gains four tests:

  • commons-fileupload2-jakarta:2.0.0-M1 → commons-fileupload2-jakarta-servlet5:2.0.0-M5
  • 1.x core, disk and servlet types → FileUpload 2 packages and names
  • the fileupload2.jakarta milestone package → fileupload2.jakarta.servlet5
  • existing jakarta.servlet5 code is left untouched

Three of the new tests fail against main and pass with this change; the fourth checks for no change, so it passes either way. JavaxToJakartaTest, JakartaEE10Test and JakartaEE11Test pass.

Comment on lines +30 to +31
spec.recipeFromResources("org.openrewrite.java.migrate.jakarta.FileuploadToFileUpload2")
.parser(JavaParser.fromJavaVersion().dependsOn(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Type table and classpath from resources

…ge-migration

# Conflicts:
#	build.gradle.kts
#	src/test/resources/META-INF/rewrite/classpath.tsv.gz
@timtebeek
timtebeek merged commit f2dabb1 into main Oct 20, 2026
2 checks passed
@timtebeek
timtebeek deleted the fix-fileupload2-package-migration branch October 20, 2026 10:35
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant