mirror of
https://github.com/correl/mage.git
synced 2025-01-13 19:11:33 +00:00
closed unclosed resources in copyCompressed method in Copier
This commit is contained in:
parent
dc25eedfc3
commit
b2e2f48ad9
1 changed files with 7 additions and 3 deletions
|
@ -79,14 +79,15 @@ public class Copier<T> {
|
|||
}
|
||||
|
||||
public byte[] copyCompressed(T obj) {
|
||||
FastByteArrayOutputStream fbos = null;
|
||||
ObjectOutputStream out = null;
|
||||
try {
|
||||
FastByteArrayOutputStream fbos = new FastByteArrayOutputStream();
|
||||
ObjectOutputStream out= new ObjectOutputStream(new GZIPOutputStream(fbos));
|
||||
fbos = new FastByteArrayOutputStream();
|
||||
out = new ObjectOutputStream(new GZIPOutputStream(fbos));
|
||||
|
||||
// Write the object out to a byte array
|
||||
out.writeObject(obj);
|
||||
out.flush();
|
||||
out.close();
|
||||
|
||||
byte[] copy = new byte[fbos.getSize()];
|
||||
System.arraycopy(fbos.getByteArray(), 0, copy, 0, fbos.getSize());
|
||||
|
@ -94,6 +95,9 @@ public class Copier<T> {
|
|||
}
|
||||
catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
StreamUtils.closeQuietly(fbos);
|
||||
StreamUtils.closeQuietly(out);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue