Commit 051aea7
authored
Fix edge cases with UTF-8 strings in ChecksumResultSet (#13441)
1. Ensure a minimum capacity of 4 bytes when allocating the buffer, this
is the max size of a UTF-8 character. However, the java length
representation is being used in this code for the byte buffer
allocation, which may be too small for a single utf-8 character.
2. Use buffer.clear() instead of the second buffer.flip() . This resets
the buffer's write limit back to its full capacity for the next
iteration, instead of shrinking it to the size of the previous write.
This is for mixed multi-byte utf-8 characters and single-byte
characters. A test was added to show this passing, and it fails with
`flip()` vs `clear()`
Fixes #134401 parent cfc6ba7 commit 051aea7
2 files changed
Lines changed: 42 additions & 3 deletions
File tree
- java-spanner/google-cloud-spanner/src
- main/java/com/google/cloud/spanner/connection
- test/java/com/google/cloud/spanner/connection
Lines changed: 4 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
330 | 330 | | |
331 | 331 | | |
332 | 332 | | |
333 | | - | |
| 333 | + | |
| 334 | + | |
334 | 335 | | |
335 | 336 | | |
336 | 337 | | |
| |||
354 | 355 | | |
355 | 356 | | |
356 | 357 | | |
357 | | - | |
358 | | - | |
| 358 | + | |
| 359 | + | |
359 | 360 | | |
360 | 361 | | |
361 | 362 | | |
| |||
Lines changed: 38 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
448 | 448 | | |
449 | 449 | | |
450 | 450 | | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
451 | 489 | | |
0 commit comments