You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ca...@apache.org on 2016/10/13 02:23:54 UTC
curator git commit: CURATOR-354: explicitly close GZIP input/output
streams in GzipCompressionProvider
Repository: curator
Updated Branches:
refs/heads/CURATOR-354 [created] 8c1b4be57
CURATOR-354: explicitly close GZIP input/output streams in GzipCompressionProvider
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/8c1b4be5
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/8c1b4be5
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/8c1b4be5
Branch: refs/heads/CURATOR-354
Commit: 8c1b4be57ffaf58ce8708e0e9d3611e4e5955f2e
Parents: 022de39
Author: Evan Pollan <ev...@gmail.com>
Authored: Thu Oct 6 15:53:04 2016 -0500
Committer: Evan Pollan <ev...@gmail.com>
Committed: Thu Oct 6 15:53:04 2016 -0500
----------------------------------------------------------------------
.../framework/imps/GzipCompressionProvider.java | 26 +++++++++++++-------
1 file changed, 17 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/8c1b4be5/curator-framework/src/main/java/org/apache/curator/framework/imps/GzipCompressionProvider.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/GzipCompressionProvider.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/GzipCompressionProvider.java
index 10799bc..7b35c37 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/imps/GzipCompressionProvider.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/GzipCompressionProvider.java
@@ -31,8 +31,12 @@ public class GzipCompressionProvider implements CompressionProvider
{
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
GZIPOutputStream out = new GZIPOutputStream(bytes);
- out.write(data);
- out.finish();
+ try {
+ out.write(data);
+ out.finish();
+ } finally {
+ out.close();
+ }
return bytes.toByteArray();
}
@@ -41,15 +45,19 @@ public class GzipCompressionProvider implements CompressionProvider
{
ByteArrayOutputStream bytes = new ByteArrayOutputStream(compressedData.length);
GZIPInputStream in = new GZIPInputStream(new ByteArrayInputStream(compressedData));
- byte[] buffer = new byte[compressedData.length];
- for(;;)
- {
- int bytesRead = in.read(buffer, 0, buffer.length);
- if ( bytesRead < 0 )
+ try {
+ byte[] buffer = new byte[compressedData.length];
+ for(;;)
{
- break;
+ int bytesRead = in.read(buffer, 0, buffer.length);
+ if ( bytesRead < 0 )
+ {
+ break;
+ }
+ bytes.write(buffer, 0, bytesRead);
}
- bytes.write(buffer, 0, bytesRead);
+ } finally {
+ in.close();
}
return bytes.toByteArray();
}