beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tg...@apache.org
Subject [1/3] beam git commit: Only advance Index in CreateSource if an element exists
Date Mon, 20 Mar 2017 16:26:18 GMT
Repository: beam
Updated Branches:
  refs/heads/master 6816d9870 -> 6fa1fca4f


Only advance Index in CreateSource if an element exists

This prevents an IndexOutOfBoundsException when the index in Create
overflows.


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

Branch: refs/heads/master
Commit: 636185ea41c6f676e1eb6fe51d775638c6da895d
Parents: 6816d98
Author: Pei He <peihe0@gmail.com>
Authored: Mon Mar 20 08:46:50 2017 +0800
Committer: Thomas Groh <tgroh@google.com>
Committed: Mon Mar 20 09:23:57 2017 -0700

----------------------------------------------------------------------
 .../src/main/java/org/apache/beam/sdk/transforms/Create.java     | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/636185ea/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/Create.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/Create.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/Create.java
index ffc2d8d..fa3b412 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/Create.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/Create.java
@@ -464,11 +464,11 @@ public class Create<T> {
       @Override
       protected boolean advanceImpl() throws IOException {
         CreateSource<T> source = getCurrentSource();
-        index++;
-        if (index >= source.allElementsBytes.size()) {
+        if (index + 1 >= source.allElementsBytes.size()) {
           next = null;
           return false;
         }
+        index++;
         next =
             Optional.fromNullable(
                 CoderUtils.decodeFromByteArray(source.coder, source.allElementsBytes.get(index)));


Mime
View raw message