On Tue, 13 Oct 2026 17:25:49 GMT, Justin Lu <[email protected]> wrote:

> This PR fixes a bug in `CachedRowSet` when insertion into a table with more 
> primary key columns than columns selected by the row set causes 
> `ArrayIndexOutOfBoundsException`.
> 
> This occurs because the code erroneously allocates the `primaryKeys` array to 
> size `icolCount`. So if there are more pks than cols selected, the code will 
> naturally index an out of bounds index in the array. Instead, the code should 
> use an `ArrayList` because the count of the pks is not yet known. This is 
> also hinted at considering the previous code was incrementing a `k` to figure 
> out the key size.
> 
> We can also process the primary keys such that they are only built once 
> instead of building them for every single row for a given `writeData` op.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

This pull request has now been integrated.

Changeset: 201a6645
Author:    Justin Lu <[email protected]>
URL:       
https://git.openjdk.org/jdk/commit/201a66451c16273ec7f780fbb76ce219bf08af68
Stats:     175 lines in 2 files changed: 161 ins; 10 del; 4 mod

8394152: CachedRowSet.acceptChanges throws ArrayIndexOutOfBoundsException when 
the table has more primary-key columns than selected columns

Reviewed-by: lancea

-------------

PR: https://git.openjdk.org/jdk/pull/33350

Reply via email to