Make sure to close streams when done with them.

488f8cd3b4

closes #1383
This commit is contained in:
Greg Leach 2015-03-26 19:47:38 +01:00 committed by Hans-Christoph Steiner
parent dd16906982
commit dd2f43dcde
2 changed files with 16 additions and 10 deletions

View File

@ -378,10 +378,8 @@ public class ZipSigner
Manifest input = null;
ZioEntry manifestEntry = entries.get(JarFile.MANIFEST_NAME);
if (manifestEntry != null) {
InputStream is = manifestEntry.getInputStream();
input = new Manifest();
input.read(is);
is.close();
input.read( manifestEntry.getInputStream());
}
Manifest output = new Manifest();
Attributes main = output.getMainAttributes();
@ -645,9 +643,17 @@ public class ZipSigner
progressHelper.initProgress();
progressHelper.progress( ProgressEvent.PRORITY_IMPORTANT, resourceAdapter.getString(ResourceAdapter.Item.PARSING_CENTRAL_DIRECTORY));
ZipInput input = ZipInput.read( inputZipFilename);
signZip( input.getEntries(), new FileOutputStream( outputZipFilename), outputZipFilename);
input.close();
ZipInput input = null;
OutputStream outStream = null;
try {
input = ZipInput.read( inputZipFilename);
outStream = new FileOutputStream( outputZipFilename);
signZip(input.getEntries(), outStream, outputZipFilename);
}
finally {
if(input != null) input.close();
if(outStream != null) outStream.close();
}
}
/** Sign the
@ -750,7 +756,7 @@ public class ZipSigner
}
finally {
zipOutput.close();
if (zipOutput != null) zipOutput.close();
if (canceled) {
try {
if (outputZipFilename != null) new File( outputZipFilename).delete();

View File

@ -15,6 +15,7 @@
*/
package kellinwood.zipio;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
@ -37,9 +38,8 @@ import kellinwood.logging.LoggerManager;
/**
*
*/
public class ZipInput
public class ZipInput implements Closeable
{
static LoggerInterface log;
public String inputFilename;
@ -174,6 +174,7 @@ public class ZipInput
}
}
@Override
public void close() {
if (in != null) try { in.close(); } catch( Throwable t) {}
}
@ -227,7 +228,6 @@ public class ZipInput
public int read( byte[] b, int offset, int length) throws IOException {
return in.read( b, offset, length);
}
}