PDGGK opened a new pull request, #39603:
URL: https://github.com/apache/shardingsphere/pull/39603
Changes proposed in this pull request:
- Close every statement in `JDBCDataRowEnumerator.close()`, not just the
ones before the first failure.
The close loop was inside the `try` block:
```java
public void close() {
try {
for (Statement each : statements) {
each.close();
}
currentRow = null;
} catch (final SQLException ex) {
throw new SQLWrapperException(ex);
}
}
```
`statements` holds one statement per data source the federated query
touched, so when the first one throws the loop aborts and the remaining
statements — and the server side cursors behind them — are never closed.
`currentRow` is left dangling too.
Each statement is now closed independently. The first failure is kept and
later ones are attached to it with `addSuppressed`, following
`MCPJdbcStatementExecutor#appendFailure`, so the `SQLWrapperException` a caller
already sees is unchanged and nothing is silently dropped.
Two tests in `JDBCDataRowEnumeratorTest`:
- `assertCloseClosesRemainingStatementsAfterFailure` — the first of three
statements throws; the other two are still closed and the original exception
still surfaces. Without the change this fails with `Wanted but not invoked:
secondStatement.close()`.
- `assertCloseSuppressesLaterFailures` — two failing statements; the first
is the cause and the second is suppressed rather than lost.
The three existing tests are unchanged and still pass.
---
Before committing this PR, I'm sure that I have checked the following
options:
- [x] My code follows the [code of
conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/)
of this project.
- [x] I have self-reviewed the commit code.
- [ ] I have (or in comment I request) added corresponding labels for the
pull request.
- [x] I have passed maven check locally : `./mvnw clean install -B -T1C
-Dmaven.javadoc.skip -Dmaven.jacoco.skip -e`.
- [ ] I have made corresponding changes to the documentation.
- [x] I have added corresponding unit tests for my changes.
- [ ] I have updated the Release Notes of the current development version.
For more details, see [Update Release
Note](https://shardingsphere.apache.org/community/en/involved/contribute/contributor/)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]