This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat-jakartaee-migration.git
The following commit(s) were added to refs/heads/main by this push: new 0af36b6 Provide workaround for issue #46 0af36b6 is described below commit 0af36b612e058ea75db91f8075906e1fcdea9e39 Author: Mark Thomas <ma...@apache.org> AuthorDate: Wed Apr 19 08:05:31 2023 +0100 Provide workaround for issue #46 --- CHANGES.md | 1 + src/main/java/org/apache/tomcat/jakartaee/Migration.java | 13 +++++++++++++ .../org/apache/tomcat/jakartaee/LocalStrings.properties | 1 + 3 files changed, 15 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 719a9c9..b071d4c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ - Update OSGI servlet specification versions if present in manifest file. PR[#42](https://github.com/apache/tomcat-jakartaee-migration/pull/42) provided by Ivan Furnadjiev. (markt) - Update Commons BCEL to 6.7.0. (markt) - Update Commons Compress to 1.23.0. (markt) +- Provided workaround for the known JDK bug identified as the cause of migration failures in issue [#46](https://github.com/apache/tomcat-jakartaee-migration/issues/46). (markt/ebourg) ## 1.0.6 diff --git a/src/main/java/org/apache/tomcat/jakartaee/Migration.java b/src/main/java/org/apache/tomcat/jakartaee/Migration.java index 950ce23..ba76abe 100644 --- a/src/main/java/org/apache/tomcat/jakartaee/Migration.java +++ b/src/main/java/org/apache/tomcat/jakartaee/Migration.java @@ -40,6 +40,7 @@ import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream; import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; import org.apache.commons.compress.archivers.zip.ZipFile; +import org.apache.commons.compress.archivers.zip.ZipShort; import org.apache.commons.compress.utils.SeekableInMemoryByteChannel; import org.apache.commons.io.IOUtils; import org.apache.commons.io.input.CloseShieldInputStream; @@ -55,6 +56,9 @@ public class Migration { private static final Set<String> DEFAULT_EXCLUDES = new HashSet<>(); + private static final ZipShort EXTRA_FIELD_ZIP64 = new ZipShort(1); + private static final long ZIP64_THRESHOLD_LENGTH = 0xFFFFFFFFL; + static { // Apache Commons DEFAULT_EXCLUDES.add("commons-codec-*.jar"); @@ -306,6 +310,15 @@ public class Migration { logger.log(Level.WARNING, sm.getString("migration.skipSignatureFile", srcName)); continue; } + if (srcZipEntry.getSize() > ZIP64_THRESHOLD_LENGTH || + srcZipEntry.getCompressedSize() > ZIP64_THRESHOLD_LENGTH) { + logger.log(Level.WARNING, sm.getString("migration.jdk8303866", srcName)); + } else { + // Avoid JDK bug - https://bugs.openjdk.org/browse/JDK-8303866 + if (srcZipEntry.getExtraField(EXTRA_FIELD_ZIP64) != null) { + srcZipEntry.removeExtraField(EXTRA_FIELD_ZIP64); + } + } String destName = profile.convert(srcName); if (srcZipEntry.getMethod() == ZipEntry.STORED) { ByteArrayOutputStream tempBuffer = new ByteArrayOutputStream((int) (srcZipEntry.getSize() * 1.05)); diff --git a/src/main/resources/org/apache/tomcat/jakartaee/LocalStrings.properties b/src/main/resources/org/apache/tomcat/jakartaee/LocalStrings.properties index 003ecaf..66b4285 100644 --- a/src/main/resources/org/apache/tomcat/jakartaee/LocalStrings.properties +++ b/src/main/resources/org/apache/tomcat/jakartaee/LocalStrings.properties @@ -26,6 +26,7 @@ migration.alreadyRunning=Migration is already running migration.done=Migration completed successfully in [{0}] milliseconds migration.error=Error performing migration migration.execute=Performing migration from source [{0}] to destination [{1}] with Jakarta EE specification profile [{2}] +migration.jdk8303866=Due to size of [{0}], migrated JAR will fail if used in a JDK without the fix for https://bugs.openjdk.org/browse/JDK-8303866 - Using an in memory migration rather than a streaming migration may work-around the issue. migration.mkdirError=Error creating destination directory [{0}]a migration.skip=Migration skipped for archive [{0}] because it is excluded (the archive was copied unchanged) migration.skipSignatureFile=Drop cryptographic signature file [{0}] --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org