beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From k...@apache.org
Subject [1/5] beam git commit: Return null when timer not found instead of crashing
Date Mon, 16 Oct 2017 23:00:28 GMT
Repository: beam
Updated Branches:
  refs/heads/master a5cbd764b -> 52863efd7


Return null when timer not found instead of crashing


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

Branch: refs/heads/master
Commit: e940456bd95da3c8b79eb4666ad09280dccaedcf
Parents: 655227a
Author: Kenneth Knowles <kenn@apache.org>
Authored: Mon Oct 16 15:13:26 2017 -0700
Committer: Kenneth Knowles <kenn@apache.org>
Committed: Mon Oct 16 15:17:32 2017 -0700

----------------------------------------------------------------------
 .../runners/core/InMemoryTimerInternals.java    | 28 ++++++++++----------
 1 file changed, 14 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/e940456b/runners/core-java/src/main/java/org/apache/beam/runners/core/InMemoryTimerInternals.java
----------------------------------------------------------------------
diff --git a/runners/core-java/src/main/java/org/apache/beam/runners/core/InMemoryTimerInternals.java
b/runners/core-java/src/main/java/org/apache/beam/runners/core/InMemoryTimerInternals.java
index c29ea19..c7b4ac6 100644
--- a/runners/core-java/src/main/java/org/apache/beam/runners/core/InMemoryTimerInternals.java
+++ b/runners/core-java/src/main/java/org/apache/beam/runners/core/InMemoryTimerInternals.java
@@ -25,6 +25,7 @@ import com.google.common.base.MoreObjects;
 import com.google.common.collect.HashBasedTable;
 import com.google.common.collect.Table;
 import java.util.NavigableSet;
+import java.util.NoSuchElementException;
 import java.util.TreeSet;
 import javax.annotation.Nullable;
 import org.apache.beam.sdk.state.TimeDomain;
@@ -71,21 +72,20 @@ public class InMemoryTimerInternals implements TimerInternals {
    */
   @Nullable
   public Instant getNextTimer(TimeDomain domain) {
-    final TimerData data;
-    switch (domain) {
-      case EVENT_TIME:
-        data = watermarkTimers.first();
-        break;
-      case PROCESSING_TIME:
-        data = processingTimers.first();
-        break;
-      case SYNCHRONIZED_PROCESSING_TIME:
-        data = synchronizedProcessingTimers.first();
-        break;
-      default:
-        throw new IllegalArgumentException("Unexpected time domain: " + domain);
+    try {
+      switch (domain) {
+        case EVENT_TIME:
+          return watermarkTimers.first().getTimestamp();
+        case PROCESSING_TIME:
+          return processingTimers.first().getTimestamp();
+        case SYNCHRONIZED_PROCESSING_TIME:
+          return synchronizedProcessingTimers.first().getTimestamp();
+        default:
+          throw new IllegalArgumentException("Unexpected time domain: " + domain);
+      }
+    } catch (NoSuchElementException exc) {
+      return null;
     }
-    return (data == null) ? null : data.getTimestamp();
   }
 
   private NavigableSet<TimerData> timersForDomain(TimeDomain domain) {


Mime
View raw message