> Within `writeData`, an insert statement is being created for every inserted 
> row. This is redundant because the insertion statement remains the same 
> between inserted rows. (i.e., all columns are included and the values are 
> supplied in `insertNewRow`). What is problematic is that the final insert 
> statement is the only one being closed. Additionally, if the code throws an 
> exception, then this final insert statement does not get closed as well.
> 
> This PR
> - Ensures the statement is created only once (and closed)
> - Ensures that if the code throws an exception, the statement is still closed
> 
> Note that the `finally` block follows similar to behavior to that in 
> `CachedRowSetReader.readData`, where the exception that could occur in the 
> `close` is discarded, if the original code already threw an exception. I did 
> not find it necessary here to retain the closed exception via `addSuppressed` 
> if the original code also threw.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

Justin Lu has updated the pull request incrementally with one additional commit 
since the last revision:

  Use addSupressed to mimic try-with-resources behavior

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/33639/files
  - new: https://git.openjdk.org/jdk/pull/33639/files/426d2f2f..a3983888

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=33639&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=33639&range=00-01

  Stats: 7 lines in 1 file changed: 2 ins; 0 del; 5 mod
  Patch: https://git.openjdk.org/jdk/pull/33639.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/33639/head:pull/33639

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

Reply via email to