Make sure to close streams when done with them.
488f8cd3b4
closes #1383
This commit is contained in:
parent
dd16906982
commit
dd2f43dcde
@ -378,10 +378,8 @@ public class ZipSigner
|
|||||||
Manifest input = null;
|
Manifest input = null;
|
||||||
ZioEntry manifestEntry = entries.get(JarFile.MANIFEST_NAME);
|
ZioEntry manifestEntry = entries.get(JarFile.MANIFEST_NAME);
|
||||||
if (manifestEntry != null) {
|
if (manifestEntry != null) {
|
||||||
InputStream is = manifestEntry.getInputStream();
|
|
||||||
input = new Manifest();
|
input = new Manifest();
|
||||||
input.read(is);
|
input.read( manifestEntry.getInputStream());
|
||||||
is.close();
|
|
||||||
}
|
}
|
||||||
Manifest output = new Manifest();
|
Manifest output = new Manifest();
|
||||||
Attributes main = output.getMainAttributes();
|
Attributes main = output.getMainAttributes();
|
||||||
@ -645,9 +643,17 @@ public class ZipSigner
|
|||||||
progressHelper.initProgress();
|
progressHelper.initProgress();
|
||||||
progressHelper.progress( ProgressEvent.PRORITY_IMPORTANT, resourceAdapter.getString(ResourceAdapter.Item.PARSING_CENTRAL_DIRECTORY));
|
progressHelper.progress( ProgressEvent.PRORITY_IMPORTANT, resourceAdapter.getString(ResourceAdapter.Item.PARSING_CENTRAL_DIRECTORY));
|
||||||
|
|
||||||
ZipInput input = ZipInput.read( inputZipFilename);
|
ZipInput input = null;
|
||||||
signZip( input.getEntries(), new FileOutputStream( outputZipFilename), outputZipFilename);
|
OutputStream outStream = null;
|
||||||
input.close();
|
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
|
/** Sign the
|
||||||
@ -750,7 +756,7 @@ public class ZipSigner
|
|||||||
|
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
zipOutput.close();
|
if (zipOutput != null) zipOutput.close();
|
||||||
if (canceled) {
|
if (canceled) {
|
||||||
try {
|
try {
|
||||||
if (outputZipFilename != null) new File( outputZipFilename).delete();
|
if (outputZipFilename != null) new File( outputZipFilename).delete();
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package kellinwood.zipio;
|
package kellinwood.zipio;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.RandomAccessFile;
|
import java.io.RandomAccessFile;
|
||||||
@ -37,9 +38,8 @@ import kellinwood.logging.LoggerManager;
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ZipInput
|
public class ZipInput implements Closeable
|
||||||
{
|
{
|
||||||
|
|
||||||
static LoggerInterface log;
|
static LoggerInterface log;
|
||||||
|
|
||||||
public String inputFilename;
|
public String inputFilename;
|
||||||
@ -174,6 +174,7 @@ public class ZipInput
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
if (in != null) try { in.close(); } catch( Throwable t) {}
|
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 {
|
public int read( byte[] b, int offset, int length) throws IOException {
|
||||||
return in.read( b, offset, length);
|
return in.read( b, offset, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user