allthingssecurity opened a new pull request, #29401: URL: https://github.com/apache/camel/pull/29401
# Description [CAMEL-26704](https://issues.apache.org/jira/browse/CAMEL-26704) `DefaultJdbcOptimisticLockingExceptionMapper.isConstraintViolation` called `e.getSQLState().startsWith("23")`, but the SQLState is optional in JDBC. Connection pools can report a pool timeout without one (Agroal, and HikariCP's `SQLTransientConnectionException` when the pool is exhausted). The mapper walks the cause chain from the root cause up, so the first `SQLException` without SQLState threw a `NullPointerException` before the `DataIntegrityViolationException` and class-name checks ran. Its only caller is the `catch` in `JdbcAggregationRepository.add(camelContext, key, oldExchange, newExchange)` (aggregate EIP with optimistic locking), where the NPE replaced the real exception: the SQL error was lost and `onException(SQLException.class)` no longer matched. Change (`DefaultJdbcOptimisticLockingExceptionMapper`): an `SQLException` without SQLState is not a constraint violation, so the other checks still run. Nothing else changes; for any SQLState the result is the same as before. Tests: `DefaultJdbcOptimisticLockingExceptionMapperTest` (an SQLException without SQLState, wrapped in a `CannotCreateTransactionException` as Spring does for a pool timeout; the same with a configured vendor class name further up the chain; control: SQLState 23505 and 08001). On main the first two fail with the NPE and the control passes; with the fix 3/3, and 60/60 over 20 runs. camel-sql module tests: 339 run (offline, both changes together), 0 failures; 2 errors in `SqlFunctionDataSourceTest`, which installs an embedded MariaDB and cannot run offline here (unrelated to this change). # Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) # Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it): [CAMEL-26704](https://issues.apache.org/jira/browse/CAMEL-26704). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes. (I built the core modules and camel-sql with the formatter and import-sort plugins and ran the camel-sql tests; no generated file changes. I did not run the full root build.) # AI-assisted contributions - [x] If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR description identifies the AI tool used. This PR was prepared with Claude Code (Claude Opus 5.5). The commit carries a `Co-Authored-By` trailer. _Claude Code on behalf of allthingssecurity_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
