-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit acc8ed6
Add stream-key auto-conversion for ByteRecord
Add automatic type conversion logic in StreamRecords.ofBytes() method
to handle different stream key types safely. This resolves the TODO
comment and prevents ClassCastException when using String or ByteBuffer
stream keys without RedisTemplate.
Supported conversions:
- String to byte[] using UTF-8 encoding
- ByteBuffer to byte[] by copying buffer contents
- byte[] passed through unchanged
- null values handled gracefully
- Unsupported types throw IllegalArgumentException with clear message
The implementation follows the same pattern as the existing ofBuffer()
method for consistency. This improvement enhances developer experience
when working directly with Redis connections instead of RedisTemplate,
particularly useful for performance-critical scenarios or custom
serialization requirements.
Added comprehensive test coverage including edge cases and error
handling to ensure robust behavior across all supported input types.
Signed-off-by: Seo Bo Gyeong <dodu7510@gmail.com>1 parent 5fe3e38 commit acc8ed6
File tree
2 files changed
+88
-2
lines changed- src
- main/java/org/springframework/data/redis/connection/stream
- test/java/org/springframework/data/redis/connection
2 files changed
+88
-2
lines changedLines changed: 19 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
30 | 30 |
| |
31 | 31 |
| |
32 | 32 |
| |
33 | + | ||
33 | 34 |
| |
34 | 35 |
| |
35 | 36 |
| |
| |||
197 | 198 |
| |
198 | 199 |
| |
199 | 200 |
| |
200 | - | ||
201 | - | ||
201 | + | ||
202 | + | ||
203 | + | ||
204 | + | ||
205 | + | ||
206 | + | ||
207 | + | ||
208 | + | ||
209 | + | ||
210 | + | ||
211 | + | ||
212 | + | ||
213 | + | ||
214 | + | ||
215 | + | ||
216 | + | ||
217 | + | ||
218 | + | ||
202 | 219 |
| |
203 | 220 |
| |
204 | 221 |
| |
|
Lines changed: 69 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
18 | 18 |
| |
19 | 19 |
| |
20 | 20 |
| |
21 | + | ||
21 | 22 |
| |
22 | 23 |
| |
23 | 24 |
| |
| |||
164 | 165 |
| |
165 | 166 |
| |
166 | 167 |
| |
168 | + | ||
169 | + | ||
170 | + | ||
171 | + | ||
172 | + | ||
173 | + | ||
174 | + | ||
175 | + | ||
176 | + | ||
177 | + | ||
178 | + | ||
179 | + | ||
180 | + | ||
181 | + | ||
182 | + | ||
183 | + | ||
184 | + | ||
185 | + | ||
186 | + | ||
187 | + | ||
188 | + | ||
189 | + | ||
190 | + | ||
191 | + | ||
192 | + | ||
193 | + | ||
194 | + | ||
195 | + | ||
196 | + | ||
197 | + | ||
198 | + | ||
199 | + | ||
200 | + | ||
201 | + | ||
202 | + | ||
203 | + | ||
204 | + | ||
205 | + | ||
206 | + | ||
207 | + | ||
208 | + | ||
209 | + | ||
210 | + | ||
211 | + | ||
212 | + | ||
213 | + | ||
214 | + | ||
215 | + | ||
216 | + | ||
217 | + | ||
218 | + | ||
219 | + | ||
220 | + | ||
221 | + | ||
222 | + | ||
223 | + | ||
224 | + | ||
225 | + | ||
226 | + | ||
227 | + | ||
228 | + | ||
229 | + | ||
230 | + | ||
231 | + | ||
232 | + | ||
233 | + | ||
234 | + | ||
235 | + | ||
167 | 236 |
|
0 commit comments