Skip to content

#778 Allow specifying closeable type when closing it via ThreadCloseableRegistry. - #779

Merged
yruslan merged 3 commits into
mainfrom
feature/778-improve-logging-closeables
Jul 22, 2026
Merged

#778 Allow specifying closeable type when closing it via ThreadCloseableRegistry.#779
yruslan merged 3 commits into
mainfrom
feature/778-improve-logging-closeables

Conversation

@yruslan

@yruslan yruslan commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Overview

Improves logging of automatic closing of autocloseables when the thread is terminated.

Release Notes

  • Improves logging of automatic closing of autocloseables when the thread is terminated

Related

Closes #778

Summary by CodeRabbit

  • Bug Fixes
    • Improved cleanup of database statements and connections during query execution and shutdown.
    • Enhanced close handling to avoid duplicate close attempts and provide clearer close logging context.
    • Preserved metadata escaping behavior while reorganizing its implementation for consistency.
  • Tests
    • Expanded registry cleanup coverage, including double-close scenarios and expected close behavior.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@yruslan, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 31 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a1409b93-a3a5-4cb6-8d52-16cf4b9fcd79

📥 Commits

Reviewing files that changed from the base of the PR and between d48c2b2 and 2932aa7.

📒 Files selected for processing (1)
  • pramen/core/src/main/scala/za/co/absa/pramen/core/runner/task/ThreadClosableRegistry.scala

Walkthrough

ThreadClosableRegistry now reports unregistration status, supports descriptive closeable types, and prevents duplicate closing. QueryExecutorJdbc uses the updated cleanup API, while metadata escaping moves to its companion object and its test call site is updated.

Changes

Closeable lifecycle and JDBC updates

Layer / File(s) Summary
Closeable cleanup contract
pramen/core/src/main/scala/za/co/absa/pramen/core/runner/task/ThreadClosableRegistry.scala, pramen/core/src/test/scala/za/co/absa/pramen/core/tests/runner/task/ThreadClosableRegistrySuite.scala
closeCloseable accepts descriptive type text, uses unregistration status to avoid repeated closes, and tests cover already-closed and double-close behavior.
JDBC integration and metadata utility
pramen/core/src/main/scala/za/co/absa/pramen/core/utils/hive/QueryExecutorJdbc.scala, pramen/core/src/test/scala/za/co/absa/pramen/core/tests/utils/hive/QueryExecutorJdbcSuite.scala
JDBC statement and connection cleanup pass closeable reasons through the registry; getEscapedMetadataString moves to the companion object with unchanged logic and updated test access.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related PRs

  • AbsaOSS/pramen#723: Refines related ThreadClosableRegistry and QueryExecutorJdbc lifecycle wiring.
  • AbsaOSS/pramen#777: Updates closeable lifecycle behavior and JDBC cleanup integration.

Poem

A rabbit checks each closing call,
No duplicate hops at all.
JDBC names its cleanup tune,
Metadata finds its companion moon.
Hop, hop—clean logs bloom!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning QueryExecutorJdbc's metadata helper move is unrelated to closeable logging and appears outside #778. Keep the PR focused on logging changes, or split the QueryExecutorJdbc refactor and its test updates into a separate PR.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: adding a closeable type when closing through ThreadClosableRegistry.
Description check ✅ Passed The description includes an Overview, Release Notes, and the linked issue reference, matching the template.
Linked Issues check ✅ Passed The changes address #778 by letting closeCloseable accept a type and logging it instead of null.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/778-improve-logging-closeables

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@pramen/core/src/main/scala/za/co/absa/pramen/core/utils/hive/QueryExecutorJdbc.scala`:
- Line 95: Update both closeCloseable calls in QueryExecutorJdbc at lines 95 and
108 to match ThreadClosableRegistry’s available one-argument signature by
removing the reason-string argument, or add a compatible overload to
ThreadClosableRegistry and use it consistently at both sites.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cd1ad514-961c-4c76-814f-7d60dcc13242

📥 Commits

Reviewing files that changed from the base of the PR and between 6c87f60 and 0f90c79.

📒 Files selected for processing (1)
  • pramen/core/src/main/scala/za/co/absa/pramen/core/utils/hive/QueryExecutorJdbc.scala

@yruslan
yruslan force-pushed the feature/778-improve-logging-closeables branch from 0f90c79 to b8ef1fa Compare July 22, 2026 06:23
@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown

Unit Test Coverage

Overall Project 76.83% -0.02% 🍏
Files changed 83.49% 🍏

Module Coverage
pramen:core Jacoco Report 77.81% -0.02% 🍏
Files
Module File Coverage
pramen:core Jacoco Report QueryExecutorJdbc.scala 79.46% 🍏
ThreadClosableRegistry.scala 78.63% -7.26%

@yruslan

yruslan commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@pramen/core/src/main/scala/za/co/absa/pramen/core/runner/task/ThreadClosableRegistry.scala`:
- Around line 58-65: Extract the canonical-name fallback logic from
closeableTypeFixed into a shared safe type resolver, then reuse it in both
closeCloseable and cleanupThread. Replace cleanupThread’s direct
closeable.getClass.getCanonicalName interpolation with the resolver so anonymous
AutoCloseable implementations produce a non-null type name.
- Around line 83-92: Update cleanupThread to call close() only when
unregisterCloseable returns true, ensuring a resource removed concurrently by
closeCloseable is not closed again. Add a concurrent regression test covering
this race and verifying close-once behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 43155f10-3f03-4f8a-9add-03d6cd890ad9

📥 Commits

Reviewing files that changed from the base of the PR and between 0f90c79 and d48c2b2.

📒 Files selected for processing (4)
  • pramen/core/src/main/scala/za/co/absa/pramen/core/runner/task/ThreadClosableRegistry.scala
  • pramen/core/src/main/scala/za/co/absa/pramen/core/utils/hive/QueryExecutorJdbc.scala
  • pramen/core/src/test/scala/za/co/absa/pramen/core/tests/runner/task/ThreadClosableRegistrySuite.scala
  • pramen/core/src/test/scala/za/co/absa/pramen/core/tests/utils/hive/QueryExecutorJdbcSuite.scala
🚧 Files skipped from review as they are similar to previous changes (1)
  • pramen/core/src/main/scala/za/co/absa/pramen/core/utils/hive/QueryExecutorJdbc.scala

… across methods in ThreadClosableRegistry.
@yruslan
yruslan merged commit 5debe77 into main Jul 22, 2026
7 checks passed
@yruslan
yruslan deleted the feature/778-improve-logging-closeables branch July 22, 2026 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve logging of closeables

1 participant