beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lc...@apache.org
Subject [1/2] beam git commit: [BEAM-2130] Ensure the options id is never null.
Date Mon, 01 May 2017 16:40:42 GMT
Repository: beam
Updated Branches:
  refs/heads/master 8a1fab1d1 -> fe2a32000


[BEAM-2130] Ensure the options id is never null.


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

Branch: refs/heads/master
Commit: 13435e626df82d08a8f7f2032e46a6160d172b29
Parents: 8a1fab1
Author: Lukasz Cwik <lcwik@google.com>
Authored: Sun Apr 30 16:43:33 2017 -0700
Committer: Luke Cwik <lcwik@google.com>
Committed: Mon May 1 09:38:42 2017 -0700

----------------------------------------------------------------------
 .../org/apache/beam/sdk/options/PipelineOptions.java  |  4 ++--
 .../apache/beam/sdk/options/PipelineOptionsTest.java  | 14 ++++++++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/13435e62/sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptions.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptions.java
b/sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptions.java
index 063eac4..d423bfa 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptions.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptions.java
@@ -334,8 +334,8 @@ public interface PipelineOptions extends HasDisplayData {
    */
   @Hidden
   @Default.InstanceFactory(AtomicLongFactory.class)
-  Long getOptionsId();
-  void setOptionsId(Long id);
+  long getOptionsId();
+  void setOptionsId(long id);
 
   /**
    * {@link DefaultValueFactory} which supplies an ID that is guaranteed to be unique

http://git-wip-us.apache.org/repos/asf/beam/blob/13435e62/sdks/java/core/src/test/java/org/apache/beam/sdk/options/PipelineOptionsTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/org/apache/beam/sdk/options/PipelineOptionsTest.java
b/sdks/java/core/src/test/java/org/apache/beam/sdk/options/PipelineOptionsTest.java
index 62f53e4..a13aa01 100644
--- a/sdks/java/core/src/test/java/org/apache/beam/sdk/options/PipelineOptionsTest.java
+++ b/sdks/java/core/src/test/java/org/apache/beam/sdk/options/PipelineOptionsTest.java
@@ -19,9 +19,12 @@ package org.apache.beam.sdk.options;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
 
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.google.common.collect.ImmutableMap;
+
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -93,4 +96,15 @@ public class PipelineOptionsTest {
         "bool", ImmutableMap.of("type", Boolean.class));
     assertEquals(expected, options.outputRuntimeOptions());
   }
+
+  @Test
+  public void testPipelineOptionsIdIsUniquePerInstance() {
+    Set<Long> ids = new HashSet<Long>();
+    for (int i = 0; i < 1000; ++i) {
+      long id = PipelineOptionsFactory.create().getOptionsId();
+      if (!ids.add(id)) {
+        fail(String.format("Generated duplicate id %s, existing generated ids %s", id, ids));
+      }
+    }
+  }
 }


Mime
View raw message