Commit 3dc12d6
committed
fix: handle different Redis return types for num_docs field (#639)
Fix ClassCastException when retrieving document count from Redis index info.
Redis can return num_docs as either String or Long depending on version/config.
Applied robust type checking to all occurrences:
- RedisJSONKeyValueAdapter.count()
- RedisEnhancedKeyValueAdapter.count()
- RedisFluentQueryByExample (already fixed in SearchStreamImpl)
The fix handles:
- String values: parse to Long
- Number values: convert to long
- Null/unexpected: return 0L safely
This is more robust than PR #640's approach as it:
- Handles multiple Redis return types
- Avoids NullPointerException
- Prevents unnecessary String conversions
- Provides safe fallback for unexpected types1 parent 2d734bf commit 3dc12d6
File tree
3 files changed
+42
-3
lines changed- redis-om-spring/src/main/java/com/redis/om/spring
- search/stream
3 files changed
+42
-3
lines changedLines changed: 15 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
392 | 392 | | |
393 | 393 | | |
394 | 394 | | |
395 | | - | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
396 | 410 | | |
397 | 411 | | |
398 | 412 | | |
| |||
Lines changed: 16 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
346 | 347 | | |
347 | 348 | | |
348 | 349 | | |
349 | | - | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
350 | 365 | | |
351 | 366 | | |
352 | 367 | | |
| |||
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
274 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
275 | 285 | | |
276 | 286 | | |
277 | 287 | | |
| |||
0 commit comments