-
Notifications
You must be signed in to change notification settings - Fork 10
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
Jars generated through TinyBundles 3.0.0 have a MANIFEST.MF file with a system LastModified date in 2106 #46
Comments
I have checked and compared Tinybundles 3.0.0 with bndlib 3.5.0 to tinybundles 1.0.0 and bndlib 1.43.0, the previous version we used. It appears that the change that introduced this change in date representation was in bndlib. Apparently, the Jar.class doManifest() method has been updated in recent versions to use the lastModified date used in the Jar as the new value for the lastModified system property for the MANIFEST.MF file, adjusted by the JVM timezone offset. However, tinybundles sets this lastModified date to 0 (or rather doesn't pass it as a parameter), leading to this date potentially being negative when used in timezones with a positive offset from UTC, because the ZipUtil class bndlib uses to set this LastModified property subtracts the offset from the modified time, leading to a situation where the Lastmodified time for the MANIFEST.MF entry may be negative, or rather, since it's an unsigned integer, underflowing. |
Cannot reproduce. The timestamp ( |
It's not the Bnd-LastModified: timestamp that I'm talking about. it's the actual Windows "Last Modified" date system property that is the issue:
If you inspect the jar using 7Zip, you'll see that the MANIFEST.MF file has the Last Modified Date set to sometime in 2106. |
@ikannak Can you please create a test case against latest TinyBundles snapshot? I don't have a local Windows for testing, but CI is now running on Windows also. |
We started noticing this last Saturday, but it appears to be happening in our code at least since we updated TinyBundles to 3.0.0 in 2020. We allow customers to automatically generate bnd jar bundles for use in Karaf using tinybundles 3.0.0, using the following code:
With writeJar being the following method:
This might look like a lot of unnecessary code, but I have tested this with JUST:
So with essentially an empty bundle, and the Manifest.MF file was still generated with a LastModifed system date that was set in 2106. This does not affect the functionality of the jar (it still works in the way that we expect it to) and it can safely be unpacked using tools like 7zip, and it can also be read as a Java Jar class. The main issue this brings is that a custom unzip process using native Java code needs to account for this, because if this LastModified property is used directly for the same property on a Java File object, it fails with error java.lang.IllegalArgumentException: Negative time
at java.base/java.io.File.setLastModified(File.java:1441)
I have attached a zip file containing an example jar as generated by the second code snippet.
TestScriptingPhaseBlueprintAndBundleGeneration-1.0.0.jar.zip
The text was updated successfully, but these errors were encountered: