ryantenney / passkit4j

Java library for generating Apple Passbook (.pkpass) files
http://www.ryantenney.com/passkit4j/
Apache License 2.0
80 stars 50 forks source link

Can't create passfile: PassSerializationException: Error closing output stream #6

Closed fkrauthan closed 11 years ago

fkrauthan commented 11 years ago

If I call this PassSerializer.writePkPassArchive(pass, signer, byteOutputStream); I the following exception:

Caused by: com.ryantenney.passkit4j.PassSerializationException: Error closing output stream
        at com.ryantenney.passkit4j.PassSerializer.writePkPassArchive(PassSerializer.java:76)
        at com.***.service.passbook.PassbookGeneratorServiceLocalServiceBean.generatePass(PassbookGeneratorServiceLocalServiceBean.java:143)
        ... 85 more
Caused by: java.util.zip.ZipException: ZIP file must have at least one entry
        at java.util.zip.ZipOutputStream.finish(ZipOutputStream.java:304)
        at java.util.zip.DeflaterOutputStream.close(DeflaterOutputStream.java:140)
        at java.util.zip.ZipOutputStream.close(ZipOutputStream.java:321)
        at com.ryantenney.passkit4j.PassSerializer.writePkPassArchive(PassSerializer.java:74)
        ... 86 more
|#]
fkrauthan commented 11 years ago

Found the issue. If you don't add any files to a pass then files is null and the foreach throws a Exception.

ryantenney commented 11 years ago

Good to know! I'll add a null-check and instead of rethrowing the IOException from the call to close() I'll just log it instead?

fkrauthan commented 11 years ago

The IOException is thrown because of the nullpointer. So I think it is enough if you add the null pointer check.