beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dhalp...@apache.org
Subject [1/2] beam git commit: BEAM-1567 hashStream should be closed in PackageUtil#createPackageAttributes()
Date Thu, 02 Mar 2017 16:19:13 GMT
Repository: beam
Updated Branches:
  refs/heads/master 6a33dc666 -> b322a5d40


BEAM-1567 hashStream should be closed in PackageUtil#createPackageAttributes()


Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/a7f69bd2
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/a7f69bd2
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/a7f69bd2

Branch: refs/heads/master
Commit: a7f69bd2d2fcf5a4852739e3b3a9b705fa7b1fb5
Parents: 6a33dc6
Author: tedyu <yuzhihong@gmail.com>
Authored: Mon Feb 27 16:28:19 2017 -0800
Committer: Dan Halperin <dhalperi@google.com>
Committed: Thu Mar 2 08:18:56 2017 -0800

----------------------------------------------------------------------
 .../apache/beam/runners/dataflow/util/PackageUtil.java | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/a7f69bd2/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/util/PackageUtil.java
----------------------------------------------------------------------
diff --git a/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/util/PackageUtil.java
b/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/util/PackageUtil.java
index 482ddd9..0d52c5d 100644
--- a/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/util/PackageUtil.java
+++ b/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/util/PackageUtil.java
@@ -90,14 +90,12 @@ class PackageUtil {
    */
   static PackageAttributes createPackageAttributes(File source,
       String stagingPath, @Nullable String overridePackageName) {
-    try {
-      boolean directory = source.isDirectory();
-
-      // Compute size and hash in one pass over file or directory.
-      Hasher hasher = Hashing.md5().newHasher();
-      OutputStream hashStream = Funnels.asOutputStream(hasher);
-      CountingOutputStream countingOutputStream = new CountingOutputStream(hashStream);
+    boolean directory = source.isDirectory();
 
+    // Compute size and hash in one pass over file or directory.
+    Hasher hasher = Hashing.md5().newHasher();
+    OutputStream hashStream = Funnels.asOutputStream(hasher);
+    try (CountingOutputStream countingOutputStream = new CountingOutputStream(hashStream))
{
       if (!directory) {
         // Files are staged as-is.
         Files.asByteSource(source).copyTo(countingOutputStream);
@@ -105,6 +103,7 @@ class PackageUtil {
         // Directories are recursively zipped.
         ZipFiles.zipDirectory(source, countingOutputStream);
       }
+      countingOutputStream.flush();
 
       long size = countingOutputStream.getCount();
       String hash = Base64Variants.MODIFIED_FOR_URL.encode(hasher.hash().asBytes());


Mime
View raw message