[1/2] curator git commit: CURATOR-354: explicitly close GZIP input/output streams in GzipCompressionProvider
Repository: curator Updated Branches: refs/heads/CURATOR-3.0 3735b50ba -> 693211e41 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-3.0 Commit: 8c1b4be57ffaf58ce8708e0e9d3611e4e5955f2e Parents: 022de39 Author: Evan PollanAuthored: Thu Oct 6 15:53:04 2016 -0500 Committer: Evan Pollan 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(); GZIPOutputStreamout = 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(); }
curator git commit: CURATOR-354: explicitly close GZIP input/output streams in GzipCompressionProvider
Repository: curator Updated Branches: refs/heads/master 022de3921 -> 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/master Commit: 8c1b4be57ffaf58ce8708e0e9d3611e4e5955f2e Parents: 022de39 Author: Evan PollanAuthored: Thu Oct 6 15:53:04 2016 -0500 Committer: Evan Pollan 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(); GZIPOutputStreamout = 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(); }
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 PollanAuthored: Thu Oct 6 15:53:04 2016 -0500 Committer: Evan Pollan 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(); GZIPOutputStreamout = 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(); }