Reading the MANIFEST.MF: optimization and workaround for suspicious jars
------------------------------------------------------------------------
Key: BUILDR-524
URL: https://issues.apache.org/jira/browse/BUILDR-524
Project: Buildr
Issue Type: Improvement
Components: Core features
Affects Versions: 1.4.2
Reporter: Hugues Malphettes
When trying to read a jar's manifest with
::Buildr::Packaging::Java::Manifest.from_zip
We observed a crash "cant dup nilClass" line 1132 of zip.rb
It turns out that the jar generated by maven-3-beta contains a suspicious entry
for the META-INF/maven folder.
Opening this jar with kde's ark that entry's permissions is marked as ?rwxrwxrwx
Opening this jar with gnome's archive utility that entry has a transparent
blank icon and a size of 0 bytes: neither a file neither folder
Anyways, java is content and linux is happy unzipping this jar without
complains.
A workaround to read the manifest of such jar is to use in
lib/buildr/java/packaging.rb around line 54:
# :call-seq:
# from_zip(file) => manifest
#
# Parse the MANIFEST.MF entry of a ZIP (or JAR) file and return a new Manifest.
def from_zip(file)
Zip::ZipInputStream::open(file.to_s) { |io|
while (entry = io.get_next_entry)
if entry.name == 'META-INF/MANIFEST.MF'
return Manifest.parse io.read rescue Manifest.new
end
end
}
return Manifest.new
# Zip::ZipFile.open(file.to_s) do |zip|
# Manifest.parse zip.read('META-INF/MANIFEST.MF') rescue
Manifest.new
# end
end
This method stops as soon as it encounters the MANIFEST.MF hence avoiding all
possible following entries.
It is a lot faster for a well formed jar where the MANIFEST is always the first
entry.
Thanks
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.