-
Notifications
You must be signed in to change notification settings - Fork 3.9k
StreamEntry (XREAD) does not support binary because it uses Map<String, String> #3566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
First of all, what is XGET? Secondly, there are |
Sorry, I meant XREAD. You are correct on the alternate XRANGE signature. But I am really using XREAD. Let me update the title and to clarify.... XREAD only is problematic. |
I see there are alternate signatures for xread as well. Let me see of those help. I found the StreamEntry ones first. Give me a few minutes to explore and will udpate. |
OK, |
Hello, I noticed that there was a draft PR (#3803) opened for this issue quite a while ago, but it hasn’t been updated in some time. I’m interested in picking up this work and continuing from where it left off — possibly by improving the previous approach or starting fresh while keeping backward compatibility in mind. Would it be okay if I proceed with a new PR for this? Please let me know if there are any concerns or preferences before I begin |
@kmularise sure, please open the new pr for this issue, I will close mine 🙇 |
- Created StreamEntryBinary class to support binary data with Map<byte[], byte[]> - Added xreadBinary, xreadBinaryAsMap, xreadGroupBinary, and xreadGroupBinaryAsMap methods to StreamBinaryCommands - Implemented binary stream builders in BuilderFactory - Added implementation in Jedis and UnifiedJedis classes - Created BinaryStreamEntryTest to verify binary stream functionality
…er, and Pooled clients TEST (redis#3566) - Introduce `BinaryStreamEntryTest` and `BinaryStreamsCommandsTestBase` following the unified test pattern - Add `ClusterBinaryStreamsCommandsTest` and `PooledBinaryStreamsCommandsTest` to cover JedisCluster and JedisPooled - Parameterize tests to run under both RESP2 and RESP3 protocols - Format BuilderFactory to conform to project formatter rules
…sequence test (redis#3566) - Refactor StreamsBinaryCommandsTest: replace Map.Entry<byte[], byte[]> with Map.Entry<byte[], StreamEntryID> for xreadBinary, xreadBinaryAsMap, xreadGroupBinary and related methods - Update tests to assert on StreamEntryBinary IDs and byte-array payloads accordingly - Add a new test case covering an illegal UTF-8 sequence (0xc3 0x28) to validate correct binary handling (issue redis#3566)
…#3566) - Introduce a Map<byte[], StreamEntryID> parameter for binary stream commands - Duplicate all existing test cases for xread, xreadAsMap, xreadGroup and xreadGroupAsMap from StreamsCommandsTest.java and replace them with xreadBinary, xreadBinaryAsMap, xreadGroupBinary and xreadGroupBinaryAsMap in StreamsBinaryCommandsTest
…dis#3566) - Duplicate all existing test cases for xread, xreadAsMap, xreadGroup and xreadGroupAsMap from StreamsCommandsTest.java and replace them with xreadBinary, xreadBinaryAsMap, xreadGroupBinary and xreadGroupBinaryAsMap in StreamsBinaryCommandsTest
- Implemented a new JedisByteMap<T> class similar to the existing JedisByteHashMap to properly handle byte array keys in Map<byte[], T> operations - This implementation ensures that `get(byte[])` operations work correctly by using proper byte array equality comparison instead of reference comparison - Fixes issues when using byte arrays as keys in stream-related operations
- Added tests for JedisByteMap similar to existing JedisByteHashMap tests
…ashMap (redis#3566) - Changed Map<byte[], byte[]> in STREAM_ENTRY_BINARY_LIST to JedisByteHashMap.
* Add binary stream support for XREAD and XREADGROUP (#3566) - Created StreamEntryBinary class to support binary data with Map<byte[], byte[]> - Added xreadBinary, xreadBinaryAsMap, xreadGroupBinary, and xreadGroupBinaryAsMap methods to StreamBinaryCommands - Implemented binary stream builders in BuilderFactory - Added implementation in Jedis and UnifiedJedis classes - Created BinaryStreamEntryTest to verify binary stream functionality * Add parameterized binary stream tests for RESP2/RESP3 in Jedis, Cluster, and Pooled clients TEST (#3566) - Introduce `BinaryStreamEntryTest` and `BinaryStreamsCommandsTestBase` following the unified test pattern - Add `ClusterBinaryStreamsCommandsTest` and `PooledBinaryStreamsCommandsTest` to cover JedisCluster and JedisPooled - Parameterize tests to run under both RESP2 and RESP3 protocols - Format BuilderFactory to conform to project formatter rules * Switch to StreamEntryID in binary stream tests and add illegal UTF-8 sequence test (#3566) - Refactor StreamsBinaryCommandsTest: replace Map.Entry<byte[], byte[]> with Map.Entry<byte[], StreamEntryID> for xreadBinary, xreadBinaryAsMap, xreadGroupBinary and related methods - Update tests to assert on StreamEntryBinary IDs and byte-array payloads accordingly - Add a new test case covering an illegal UTF-8 sequence (0xc3 0x28) to validate correct binary handling (issue #3566) * Add Map<byte[], StreamEntryID> support and binary stream tests (#3566) - Introduce a Map<byte[], StreamEntryID> parameter for binary stream commands - Duplicate all existing test cases for xread, xreadAsMap, xreadGroup and xreadGroupAsMap from StreamsCommandsTest.java and replace them with xreadBinary, xreadBinaryAsMap, xreadGroupBinary and xreadGroupBinaryAsMap in StreamsBinaryCommandsTest * Modify Map<byte[], StreamEntryID> support and binary stream tests (#3566) - Duplicate all existing test cases for xread, xreadAsMap, xreadGroup and xreadGroupAsMap from StreamsCommandsTest.java and replace them with xreadBinary, xreadBinaryAsMap, xreadGroupBinary and xreadGroupBinaryAsMap in StreamsBinaryCommandsTest * Add JedisByteMap implementation (#3566) - Implemented a new JedisByteMap<T> class similar to the existing JedisByteHashMap to properly handle byte array keys in Map<byte[], T> operations - This implementation ensures that `get(byte[])` operations work correctly by using proper byte array equality comparison instead of reference comparison - Fixes issues when using byte arrays as keys in stream-related operations * Add JedisByteMapTest (#3566) - Added tests for JedisByteMap similar to existing JedisByteHashMap tests * Changed Map<byte[], byte[]> in STREAM_ENTRY_BINARY_LIST to JedisByteHashMap (#3566) - Changed Map<byte[], byte[]> in STREAM_ENTRY_BINARY_LIST to JedisByteHashMap. * Remove varargs alternatives There is already discrepancy in API between `xread` binary variant & `xread` string one. Binary one accepts varargs for requested streams, while the string variant expects them to be provided as `Map`. Going forward xread binary methods should use Map. This commit also marks existing `List<Object> xread` one as deprecated in favor of newly introduced methods for type safety and better stream entry parsing. * Add xreadBinary and xreadGroupBinary methods to PipelineBase * Deprecate List<Object> xreadXXX in favor of newly introduced typed methods * Clean up * Java docs * STREAM_ENTRY_BINARY not used * Fix BinaryStreamEntryTest test * Add BinaryStreamsPipeline tests Added tests to cover Pipeline command executions. UnifiedJedis BinaryStreamsCommand test clean up and attempt to simplify focused on testing xreadBinary and xreadGroupBinary methods . * Test cleanup & formating * Merged & refactored a bit Jedis BinaryStreamEntryTest.java & StreamsBinaryCommandsTest to match UnifiedJedis StreamsBinaryCommandsTestBase. --------- Co-authored-by: ggivo <[email protected]>
Resolved with PR #4152 |
Uh oh!
There was an error while loading. Please reload this page.
StreamEntry uses a Map<String, String> for fields.
As a result, binary data which contains illegal utf-8 sequences get mangled.
Reproduce by using XADD with a key or value which contains an illegal utf-8 sequence like 0xc3 0x28.
Retrieve via XREAD.
Expected result -- API to get byte array instead of a String, which is lossy with illegal utf-8 sequences.
The text was updated successfully, but these errors were encountered: