[ 
https://issues.apache.org/jira/browse/ODFTOOLKIT-353?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13577801#comment-13577801
 ] 

Rob Weir commented on ODFTOOLKIT-353:
-------------------------------------

Java actually has two different ZIP reading codes, one for reading from a File 
and another from reading from stream.  The more efficient way to read a ZIP is 
to use the Table of Contents that is at the end of the ZIP file.  But this only 
works with the kind of random access you have with files.  The streaming 
approach relies on walking through the ZIP items one by one.  It is possible 
for a ZIP to be inconsistent and have the TOC and the ZIP items be out of sync. 
 I don't know if this is the case here, but that would explain what you are 
seeing.

As a test, maybe try just reading the document as a ZIP file using a 
ZipInputStream.  I would not be surprised  if you get an error when walking 
through the ZIP items.
                
> NullPointerException caused by ZipException, loading file generated by 
> LibreOffice 3.6
> --------------------------------------------------------------------------------------
>
>                 Key: ODFTOOLKIT-353
>                 URL: https://issues.apache.org/jira/browse/ODFTOOLKIT-353
>             Project: ODF Toolkit
>          Issue Type: Bug
>          Components: odfdom
>    Affects Versions: odfdom-0.8.7, odfdom-0.8.8
>         Environment: Oracle JDK 1.6.0_22 x64
> Windows 7 Professional 64 bits
> LibreOffice 3.6
>            Reporter: Jean-Baptiste Lièvremont
>         Attachments: empty.odt
>
>
> I am trying to load the attached (?) empty ODT file generated with 
> LibreOffice 3.6. I put the file on the classpath in order to be able to load 
> it through getResourceAsStream.
> The NPE is as follows:
> java.lang.NullPointerException
>       at org.odftoolkit.odfdom.pkg.ZipHelper.entriesToMap(ZipHelper.java:86)
>       at org.odftoolkit.odfdom.pkg.OdfPackage.readZip(OdfPackage.java:329)
>       at 
> org.odftoolkit.odfdom.pkg.OdfPackage.initializeZip(OdfPackage.java:324)
>       at org.odftoolkit.odfdom.pkg.OdfPackage.<init>(OdfPackage.java:220)
>       at org.odftoolkit.odfdom.pkg.OdfPackage.loadPackage(OdfPackage.java:275)
>       at 
> org.odftoolkit.odfdom.doc.OdfDocument.loadDocument(OdfDocument.java:219)
>       at 
> org.odftoolkit.odfdom.doc.OdfTextDocument.loadDocument(OdfTextDocument.java:150)
>       at (redacted)
> Debugging into ZipHelper, I found that the NPE is caused by an erroneous 
> access to the "Java.version" system property (which shoud probably read 
> "java.version" - in lowercase).
> Now, if I explicitly define Java.version (-DJava.version=1.6.0), I get the 
> following ZipException:
> java.util.zip.ZipException: invalid entry CRC (expected 0xef5e424d but got 
> 0x585c5715)
>       at java.util.zip.ZipInputStream.read(ZipInputStream.java:179)
>       at java.util.zip.ZipInputStream.closeEntry(ZipInputStream.java:100)
>       at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:78)
>       at org.odftoolkit.odfdom.pkg.ZipHelper.entriesToMap(ZipHelper.java:83)
>       at org.odftoolkit.odfdom.pkg.OdfPackage.readZip(OdfPackage.java:329)
>       at 
> org.odftoolkit.odfdom.pkg.OdfPackage.initializeZip(OdfPackage.java:324)
>       at org.odftoolkit.odfdom.pkg.OdfPackage.<init>(OdfPackage.java:220)
>       at org.odftoolkit.odfdom.pkg.OdfPackage.loadPackage(OdfPackage.java:275)
>       at 
> org.odftoolkit.odfdom.doc.OdfDocument.loadDocument(OdfDocument.java:219)
>       at 
> org.odftoolkit.odfdom.doc.OdfTextDocument.loadDocument(OdfTextDocument.java:150)
>       at (redacted)
> Of course, the file loads just fine in LibreOffice 3.6, as well as 7-Zip, but 
> e.g Word 2010 also says that it is corrupt.
> So my guess is that the ZipException is somehow provoked by an issue with 
> LibreOffice 3.6 (but should not 7-Zip also complain in case of a bad CRC ?).
> Anyhow, there is an unprotected read - and comparison - of an unexisting 
> system property.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to