Repository: incubator-beam
Updated Branches:
  refs/heads/master cab0c57c0 -> 061e6b5d8


Replace unambiguous of `throw Throwables.propagate` with definition

In the SDK the path taken by Throwables.propagate is always statically
known, and the inlined logic is more explicit and readable:

 - If an exception e is already a checked exception, Throwables.propagate(e)
   is the same as `throw new RuntimeException(e)`.
 - If an exception e is already a RuntimeException or Error,
   Throwables.propagate(e) is the same as `throw e`.


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

Branch: refs/heads/master
Commit: 9f8712c325364d71d1e6cc38bc37d5dad996cb9b
Parents: cab0c57
Author: Kenneth Knowles <[email protected]>
Authored: Wed Mar 23 09:29:45 2016 -0700
Committer: Luke Cwik <[email protected]>
Committed: Thu Mar 31 16:22:42 2016 -0700

----------------------------------------------------------------------
 .../sdk/options/PipelineOptionsFactory.java     |  4 +--
 .../sdk/runners/inprocess/InProcessCreate.java  |  3 +--
 .../dataflow/sdk/util/MutationDetectors.java    |  3 +--
 .../sdk/testing/RestoreSystemProperties.java    |  4 +--
 .../cloud/dataflow/sdk/util/GcsUtilTest.java    | 28 ++++++++++----------
 5 files changed, 19 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/9f8712c3/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/options/PipelineOptionsFactory.java
----------------------------------------------------------------------
diff --git 
a/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/options/PipelineOptionsFactory.java
 
b/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/options/PipelineOptionsFactory.java
index fe53318..988d346 100644
--- 
a/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/options/PipelineOptionsFactory.java
+++ 
b/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/options/PipelineOptionsFactory.java
@@ -603,7 +603,7 @@ public class PipelineOptionsFactory {
         COMBINED_CACHE.put(combinedPipelineOptionsInterfaces,
             new Registration<T>(allProxyClass, propertyDescriptors));
       } catch (IntrospectionException e) {
-        throw Throwables.propagate(e);
+        throw new RuntimeException(e);
       }
     }
 
@@ -618,7 +618,7 @@ public class PipelineOptionsFactory {
         INTERFACE_CACHE.put(iface,
             new Registration<T>(proxyClass, propertyDescriptors));
       } catch (IntrospectionException e) {
-        throw Throwables.propagate(e);
+        throw new RuntimeException(e);
       }
     }
     @SuppressWarnings("unchecked")

http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/9f8712c3/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/runners/inprocess/InProcessCreate.java
----------------------------------------------------------------------
diff --git 
a/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/runners/inprocess/InProcessCreate.java
 
b/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/runners/inprocess/InProcessCreate.java
index c05c8c5..efda8fc 100644
--- 
a/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/runners/inprocess/InProcessCreate.java
+++ 
b/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/runners/inprocess/InProcessCreate.java
@@ -31,7 +31,6 @@ import com.google.cloud.dataflow.sdk.values.PCollection;
 import com.google.cloud.dataflow.sdk.values.PInput;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Optional;
-import com.google.common.base.Throwables;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterators;
 import com.google.common.collect.PeekingIterator;
@@ -77,7 +76,7 @@ class InProcessCreate<T> extends ForwardingPTransform<PInput, 
PCollection<T>> {
     try {
       source = new InMemorySource<>(original.getElements(), elementCoder);
     } catch (IOException e) {
-      throw Throwables.propagate(e);
+      throw new RuntimeException(e);
     }
     PCollection<T> result = input.getPipeline().apply(Read.from(source));
     result.setCoder(elementCoder);

http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/9f8712c3/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/util/MutationDetectors.java
----------------------------------------------------------------------
diff --git 
a/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/util/MutationDetectors.java
 
b/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/util/MutationDetectors.java
index 5e4a9e9..e14c008 100644
--- 
a/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/util/MutationDetectors.java
+++ 
b/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/util/MutationDetectors.java
@@ -19,7 +19,6 @@ package com.google.cloud.dataflow.sdk.util;
 
 import com.google.cloud.dataflow.sdk.coders.Coder;
 import com.google.cloud.dataflow.sdk.coders.CoderException;
-import com.google.common.base.Throwables;
 
 import java.util.Arrays;
 import java.util.Objects;
@@ -114,7 +113,7 @@ public class MutationDetectors {
       try {
         verifyUnmodifiedThrowingCheckedExceptions();
       } catch (CoderException exn) {
-        Throwables.propagate(exn);
+        throw new RuntimeException(exn);
       }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/9f8712c3/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/testing/RestoreSystemProperties.java
----------------------------------------------------------------------
diff --git 
a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/testing/RestoreSystemProperties.java
 
b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/testing/RestoreSystemProperties.java
index cd02723..cd1b29a 100644
--- 
a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/testing/RestoreSystemProperties.java
+++ 
b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/testing/RestoreSystemProperties.java
@@ -17,8 +17,6 @@
  */
 package com.google.cloud.dataflow.sdk.testing;
 
-import com.google.common.base.Throwables;
-
 import org.junit.rules.ExternalResource;
 import org.junit.rules.TestRule;
 
@@ -46,7 +44,7 @@ public class RestoreSystemProperties extends ExternalResource 
implements TestRul
       System.getProperties().clear();
       System.getProperties().load(bais);
     } catch (IOException e) {
-      throw Throwables.propagate(e);
+      throw new RuntimeException(e);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/9f8712c3/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/util/GcsUtilTest.java
----------------------------------------------------------------------
diff --git 
a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/util/GcsUtilTest.java
 
b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/util/GcsUtilTest.java
index eaeaf07..6017969 100644
--- 
a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/util/GcsUtilTest.java
+++ 
b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/util/GcsUtilTest.java
@@ -53,7 +53,6 @@ import 
com.google.cloud.dataflow.sdk.testing.FastNanoClockAndSleeper;
 import com.google.cloud.dataflow.sdk.util.gcsfs.GcsPath;
 import com.google.cloud.hadoop.gcsio.GoogleCloudStorageReadChannel;
 import com.google.cloud.hadoop.util.ClientRequestHelper;
-import com.google.common.base.Throwables;
 import com.google.common.collect.ImmutableList;
 
 import org.junit.Rule;
@@ -142,20 +141,21 @@ public class GcsUtilTest {
     for (int i = 0; i < numThreads; i++) {
       final int currentLatch = i;
       countDownLatches[i] = new CountDownLatch(1);
-      executorService.execute(new Runnable() {
-        @Override
-        public void run() {
-          // Wait for latch N and then release latch N - 1
-          try {
-            countDownLatches[currentLatch].await();
-            if (currentLatch > 0) {
-              countDownLatches[currentLatch - 1].countDown();
+      executorService.execute(
+          new Runnable() {
+            @Override
+            public void run() {
+              // Wait for latch N and then release latch N - 1
+              try {
+                countDownLatches[currentLatch].await();
+                if (currentLatch > 0) {
+                  countDownLatches[currentLatch - 1].countDown();
+                }
+              } catch (InterruptedException e) {
+                throw new RuntimeException(e);
+              }
             }
-          } catch (InterruptedException e) {
-            throw Throwables.propagate(e);
-          }
-        }
-      });
+          });
     }
 
     // Release the last latch starting the chain reaction.

Reply via email to