Skip to content

Commit f1db480

Browse files
authored
[BACKPORT] Calculate the initial frame size of the client messages correctly (#499)
* Calculate the initial frame size of the client messages correctly While calculating the initial frame size of the client messages, we were adding `SIZE_OF_FRAME_LENGTH_AND_FLAGS` twice. That extra addition is removed from the `create_initial_buffer`. To make the `create_initial_buffer_custom` alike, I also removed the addition from there, although there was no such problem for that method. To make it work again, I have modified the protocol template to perform one less subtraction of `SIZE_OF_FRAME_LENGTH_AND_FLAGS` from the initial frame size. Also, while I was there, I have updated the `sql_execute_codec`, and added support for the newly added parameter. * add a unit test that verifies the encoded requests produce the same bytearray as the Java client * bump client version * add v5 to branch filter in test runner
1 parent ac57ce7 commit f1db480

21 files changed

+95
-23
lines changed

.github/workflows/test_runner.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ on:
33
push:
44
branches:
55
- master
6-
- 4.*.z
6+
- '[45].*.z'
77
pull_request:
88
branches:
99
- master
10-
- 4.*.z
10+
- '[45].*.z'
1111
jobs:
1212
run-tests:
1313
runs-on: ${{ matrix.os }}

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@
7272
# built documents.
7373
#
7474
# The short X.Y version.
75-
version = "5.0"
75+
version = "5.0.1"
7676
# The full version, including alpha/beta/rc tags.
77-
release = "5.0"
77+
release = "5.0.1"
7878

7979
autodoc_member_order = "bysource"
8080
autoclass_content = "both"

hazelcast/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "5.0"
1+
__version__ = "5.0.1"
22

33
# Set the default handler to "hazelcast" loggers
44
# to avoid "No handlers could be found" warnings.

hazelcast/protocol/client_message.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434

3535
# For codecs
3636
def create_initial_buffer(size, message_type, is_final=False):
37-
size += SIZE_OF_FRAME_LENGTH_AND_FLAGS
3837
buf = bytearray(size)
3938
LE_INT.pack_into(buf, 0, size)
4039
flags = _UNFRAGMENTED_MESSAGE_FLAGS
@@ -48,7 +47,6 @@ def create_initial_buffer(size, message_type, is_final=False):
4847

4948
# For custom codecs
5049
def create_initial_buffer_custom(size, is_begin_frame=False):
51-
size += SIZE_OF_FRAME_LENGTH_AND_FLAGS
5250
if is_begin_frame:
5351
# Needed for custom codecs that does not have initial frame at first
5452
# but requires later due to new fix sized parameters

hazelcast/protocol/codec/custom/address_codec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
_PORT_ENCODE_OFFSET = 2 * SIZE_OF_FRAME_LENGTH_AND_FLAGS
88
_PORT_DECODE_OFFSET = 0
9-
_INITIAL_FRAME_SIZE = _PORT_ENCODE_OFFSET + INT_SIZE_IN_BYTES - 2 * SIZE_OF_FRAME_LENGTH_AND_FLAGS
9+
_INITIAL_FRAME_SIZE = _PORT_ENCODE_OFFSET + INT_SIZE_IN_BYTES - SIZE_OF_FRAME_LENGTH_AND_FLAGS
1010

1111

1212
class AddressCodec(object):

hazelcast/protocol/codec/custom/bitmap_index_options_codec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
_UNIQUE_KEY_TRANSFORMATION_ENCODE_OFFSET = 2 * SIZE_OF_FRAME_LENGTH_AND_FLAGS
88
_UNIQUE_KEY_TRANSFORMATION_DECODE_OFFSET = 0
9-
_INITIAL_FRAME_SIZE = _UNIQUE_KEY_TRANSFORMATION_ENCODE_OFFSET + INT_SIZE_IN_BYTES - 2 * SIZE_OF_FRAME_LENGTH_AND_FLAGS
9+
_INITIAL_FRAME_SIZE = _UNIQUE_KEY_TRANSFORMATION_ENCODE_OFFSET + INT_SIZE_IN_BYTES - SIZE_OF_FRAME_LENGTH_AND_FLAGS
1010

1111

1212
class BitmapIndexOptionsCodec(object):

hazelcast/protocol/codec/custom/endpoint_qualifier_codec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
_TYPE_ENCODE_OFFSET = 2 * SIZE_OF_FRAME_LENGTH_AND_FLAGS
88
_TYPE_DECODE_OFFSET = 0
9-
_INITIAL_FRAME_SIZE = _TYPE_ENCODE_OFFSET + INT_SIZE_IN_BYTES - 2 * SIZE_OF_FRAME_LENGTH_AND_FLAGS
9+
_INITIAL_FRAME_SIZE = _TYPE_ENCODE_OFFSET + INT_SIZE_IN_BYTES - SIZE_OF_FRAME_LENGTH_AND_FLAGS
1010

1111

1212
class EndpointQualifierCodec(object):

hazelcast/protocol/codec/custom/error_holder_codec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
_ERROR_CODE_ENCODE_OFFSET = 2 * SIZE_OF_FRAME_LENGTH_AND_FLAGS
1010
_ERROR_CODE_DECODE_OFFSET = 0
11-
_INITIAL_FRAME_SIZE = _ERROR_CODE_ENCODE_OFFSET + INT_SIZE_IN_BYTES - 2 * SIZE_OF_FRAME_LENGTH_AND_FLAGS
11+
_INITIAL_FRAME_SIZE = _ERROR_CODE_ENCODE_OFFSET + INT_SIZE_IN_BYTES - SIZE_OF_FRAME_LENGTH_AND_FLAGS
1212

1313

1414
class ErrorHolderCodec(object):

hazelcast/protocol/codec/custom/index_config_codec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
_TYPE_ENCODE_OFFSET = 2 * SIZE_OF_FRAME_LENGTH_AND_FLAGS
1010
_TYPE_DECODE_OFFSET = 0
11-
_INITIAL_FRAME_SIZE = _TYPE_ENCODE_OFFSET + INT_SIZE_IN_BYTES - 2 * SIZE_OF_FRAME_LENGTH_AND_FLAGS
11+
_INITIAL_FRAME_SIZE = _TYPE_ENCODE_OFFSET + INT_SIZE_IN_BYTES - SIZE_OF_FRAME_LENGTH_AND_FLAGS
1212

1313

1414
class IndexConfigCodec(object):

hazelcast/protocol/codec/custom/member_info_codec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
_UUID_DECODE_OFFSET = 0
1313
_LITE_MEMBER_ENCODE_OFFSET = _UUID_ENCODE_OFFSET + UUID_SIZE_IN_BYTES
1414
_LITE_MEMBER_DECODE_OFFSET = _UUID_DECODE_OFFSET + UUID_SIZE_IN_BYTES
15-
_INITIAL_FRAME_SIZE = _LITE_MEMBER_ENCODE_OFFSET + BOOLEAN_SIZE_IN_BYTES - 2 * SIZE_OF_FRAME_LENGTH_AND_FLAGS
15+
_INITIAL_FRAME_SIZE = _LITE_MEMBER_ENCODE_OFFSET + BOOLEAN_SIZE_IN_BYTES - SIZE_OF_FRAME_LENGTH_AND_FLAGS
1616

1717

1818
class MemberInfoCodec(object):

0 commit comments

Comments
 (0)