Skip to content

Commit 69cfbeb

Browse files
committed
Fail fast on the METADATA group name for CP data structures
It is not possible to run the CP data structures on the metadata group name. We now fail-fast if someone tries to use the `METADATA` as the CP group name. Also, the group name comparison made case-insensitive.
1 parent 086219a commit 69cfbeb

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

hazelcast/cp.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ def get_semaphore(self, name):
155155

156156

157157
_DEFAULT_GROUP_NAME = "default"
158+
_METADATA_CP_GROUP_NAME = "metadata"
158159

159160

160161
def _without_default_group_name(name):
@@ -165,7 +166,11 @@ def _without_default_group_name(name):
165166

166167
check_true(name.find("@", idx + 1) == -1, "Custom group name must be specified at most once")
167168
group_name = name[idx + 1 :].strip()
168-
if group_name == _DEFAULT_GROUP_NAME:
169+
check_true(
170+
group_name.lower() != _METADATA_CP_GROUP_NAME,
171+
"CP data structures cannot run on the METADATA CP group!",
172+
)
173+
if group_name.lower() == _DEFAULT_GROUP_NAME:
169174
return name[:idx]
170175
return name
171176

tests/proxy/cp/cp_proxy_manager_test.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,20 @@
66
class CPProxyManagerTest(unittest.TestCase):
77
def test_without_default_group_name(self):
88
self.assertEqual("test", _without_default_group_name("test@default"))
9+
self.assertEqual("test", _without_default_group_name("test@DEFAULT"))
910
self.assertEqual("test@custom", _without_default_group_name("test@custom"))
1011

1112
def test_without_default_group_name_with_multiple_group_names(self):
1213
with self.assertRaises(AssertionError):
1314
_without_default_group_name("test@default@@default")
1415

16+
def test_without_default_group_name_with_metadata_group_name(self):
17+
with self.assertRaises(AssertionError):
18+
_without_default_group_name("test@METADATA")
19+
20+
with self.assertRaises(AssertionError):
21+
_without_default_group_name("test@metadata")
22+
1523
def test_get_object_name_for_proxy(self):
1624
self.assertEqual("test", _get_object_name_for_proxy("test@default"))
1725
self.assertEqual("test", _get_object_name_for_proxy("test@custom"))

0 commit comments

Comments
 (0)