Guard SqlChangeLogParser.generateId against null DB connection - #7719
Conversation
The buildInterimIdIndex path added in #7674 queries DATABASECHANGELOG during changelog parsing. The inner try/catch wraps only DatabaseException, missing the IllegalArgumentException thrown by PreparedStatementFactory when database.getConnection() returns null (offline mode, e.g. changelog-scope `checks run` against H2 generated SQL with no --url). Widen the inner catch from DatabaseException to Exception so the fall-back-to-"raw" path triggers for any failure surfaced by the history-service lookup. The "retries on transient failure" semantics (via computeIfAbsent's no-cache-on-throw behavior) still apply for both DatabaseException and IllegalArgumentException. Test: SqlChangeLogParserTest gains "generateId falls back to 'raw' when the index build throws a non-DatabaseException", which fails on master (IllegalArgumentException escapes generateId) and passes with this change.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesSQL Changelog ID Generation Exception Handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Claude finished @filipelautert's task in 34s —— View job Code ReviewLGTM — This fix correctly addresses the null connection regression. Summary
Issues FoundNone. The fix is minimal, focused, and the comment explains the rationale clearly. Next steps: Add one of the required labels (e.g., |
|
|
wwillard7800
left a comment
There was a problem hiding this comment.
LGTM!
Reviewed in CodeRabbit Review Stack
Summary
SqlChangeLogParser.generateIdfromDatabaseExceptiontoExceptionso thebuildInterimIdIndexpath falls back to"raw"cleanly when the JDBC connection is null.Background
PR #7674 added a
buildInterimIdIndexpath that queriesDATABASECHANGELOGduring changelog parsing. The pre-existingtry/catchonly wrapsDatabaseException, missing theIllegalArgumentExceptionthrown byPreparedStatementFactorywhendatabase.getConnection()returns null.Stack:
This is hit by, among other paths, the changelog-scope
checks runflow against H2-generated SQL with no--url.Behavior change
Behavior unchanged when a live JDBC connection is present. When the lookup fails (any reason), parsing falls back to
"raw". The "retries on transient failure" semantics provided bycomputeIfAbsent's no-cache-on-throw behavior continue to apply, for bothDatabaseExceptionandIllegalArgumentException.Tests
SqlChangeLogParserTest > generateId falls back to 'raw' when the index build throws a non-DatabaseException— fails onmain(IAE escapes), passes with this change.SqlChangeLogParserTest(7/7) green.