You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by tz...@apache.org on 2020/03/12 10:02:27 UTC

[flink-statefun] branch master updated: [hotfix] [python] AnyStateHandle should not throw when state bytes is empty

This is an automated email from the ASF dual-hosted git repository.

tzulitai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-statefun.git


The following commit(s) were added to refs/heads/master by this push:
     new 5fe0442  [hotfix] [python] AnyStateHandle should not throw when state bytes is empty
5fe0442 is described below

commit 5fe0442fd3df49235f090b8ed511cbf1ce4e0fd2
Author: Tzu-Li (Gordon) Tai <tz...@apache.org>
AuthorDate: Thu Mar 12 18:00:23 2020 +0800

    [hotfix] [python] AnyStateHandle should not throw when state bytes is empty
---
 statefun-python-sdk/statefun/core.py               | 2 +-
 statefun-python-sdk/tests/any_state_handle_test.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/statefun-python-sdk/statefun/core.py b/statefun-python-sdk/statefun/core.py
index e595788..ac32fa7 100644
--- a/statefun-python-sdk/statefun/core.py
+++ b/statefun-python-sdk/statefun/core.py
@@ -71,7 +71,7 @@ class AnyStateHandle(object):
         if self.any:
             return self.any
         if not self.value_bytes:
-            raise ValueError("Can't deserialize Any. missing bytes")
+            return None
         self.any = Any()
         self.any.ParseFromString(self.value_bytes)
         return self.any
diff --git a/statefun-python-sdk/tests/any_state_handle_test.py b/statefun-python-sdk/tests/any_state_handle_test.py
index 0031bab..d26f1c0 100644
--- a/statefun-python-sdk/tests/any_state_handle_test.py
+++ b/statefun-python-sdk/tests/any_state_handle_test.py
@@ -71,4 +71,4 @@ class AnyHandleTestCase(unittest.TestCase):
 
     def test_missing_value(self):
         handle = AnyStateHandle(None)
-        self.assertTrue(True)
+        self.assertIsNone(handle.value)