Skip to content

Commit

Permalink
Fix zip file generating: ZipOutputStream should be closed to finish z…
Browse files Browse the repository at this point in the history
…ip creating correctly

#16
  • Loading branch information
stepio committed Jan 16, 2016
1 parent 8ba5cf6 commit ebdb76b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ private byte[] createZippedPassAndReturnAsByteArray(final File tempPassDir) thro
ByteArrayOutputStream byteArrayOutputStreamForZippedPass = new ByteArrayOutputStream(); // closed with the parent ZipOutputStream
try (ZipOutputStream zipOutputStream = new ZipOutputStream(byteArrayOutputStreamForZippedPass)) {
zip(tempPassDir, tempPassDir, zipOutputStream);
return byteArrayOutputStreamForZippedPass.toByteArray();
} catch (IOException e) {
throw new PKSigningException("Error while creating a zip package", e);
}
return byteArrayOutputStreamForZippedPass.toByteArray();
}

private final void zip(final File directory, final File base, final ZipOutputStream zipOutputStream) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ private byte[] createZippedPassAndReturnAsByteArray(final Map<String, ByteBuffer
zipOutputStream.putNextEntry(entry);
IOUtils.copy(new ByteArrayInputStream(passResourceFile.getValue().array()), zipOutputStream);
}
return byteArrayOutputStreamForZippedPass.toByteArray();
} catch (IOException e) {
throw new PKSigningException("Error while creating a zip package", e);
}
return byteArrayOutputStreamForZippedPass.toByteArray();
}
}

0 comments on commit ebdb76b

Please sign in to comment.