beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dhalp...@apache.org
Subject [1/2] incubator-beam git commit: Fix double-close bug
Date Tue, 29 Nov 2016 20:19:56 GMT
Repository: incubator-beam
Updated Branches:
  refs/heads/master 0d95d8c56 -> 4ce85ed94


Fix double-close bug

The WritableByteChannel returned for GCS locations has a bug where calling close twice throws
an Exception, so we cannot safely use AutoCloseable here.


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

Branch: refs/heads/master
Commit: 0123690600ebd5f83cf485c92d6a35762428cd84
Parents: 0d95d8c
Author: sammcveety <sam.mcveety@gmail.com>
Authored: Mon Nov 28 11:26:19 2016 -0800
Committer: Dan Halperin <dhalperi@google.com>
Committed: Tue Nov 29 12:19:45 2016 -0800

----------------------------------------------------------------------
 .../org/apache/beam/runners/dataflow/DataflowRunner.java    | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/01236906/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowRunner.java
----------------------------------------------------------------------
diff --git a/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowRunner.java
b/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowRunner.java
index 03c503d..641daf4 100644
--- a/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowRunner.java
+++ b/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowRunner.java
@@ -59,7 +59,6 @@ import java.net.URISyntaxException;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.nio.channels.Channels;
-import java.nio.channels.WritableByteChannel;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -566,15 +565,13 @@ public class DataflowRunner extends PipelineRunner<DataflowPipelineJob>
{
           String.format(
               "Location must be local or on Cloud Storage, got {}.", fileLocation));
       String workSpecJson = DataflowPipelineTranslator.jobToString(newJob);
-      try (
-          WritableByteChannel writer =
-              IOChannelUtils.create(fileLocation, MimeTypes.TEXT);
-          PrintWriter printWriter = new PrintWriter(Channels.newOutputStream(writer))) {
+      try (PrintWriter printWriter = new PrintWriter(
+          Channels.newOutputStream(IOChannelUtils.create(fileLocation, MimeTypes.TEXT))))
{
         printWriter.print(workSpecJson);
         LOG.info("Printed job specification to {}", fileLocation);
       } catch (IOException ex) {
         String error =
-            String.format("Cannot create output file at {}", fileLocation);
+            String.format("Cannot create output file at %s", fileLocation);
         if (isTemplate) {
           throw new RuntimeException(error, ex);
         } else {


Mime
View raw message