Skip to content

Normalize the close protocol: close() -> release() -> tryClose() - #355

Open
dfa1 wants to merge 1 commit into
mainfrom
simplify-close
Open

dfa1 wants to merge 1 commit into
mainfrom
simplify-close

Conversation

@dfa1

@dfa1 dfa1 commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • One path: NativeObject.close() -> release() (swap the pointer once, call tryClose, log on failure) -> the class's own tryClose. NativeObjectChild.release() is the only override, wrapping it in the monitor a parent's sweep waits on and unregistering from the parents afterwards.
  • Gone: doRelease, afterRelease, NativeObjectParent's final tryClose with its tryCloseResource, and NativeDBWithBaseDB's tryCloseBaseDb/tryClosePrimary hooks.
  • A parent's own tryClose starts with releaseChildren() (EnvOptions, ReadOptions, Transaction, NativeDB, TransactionDB, OptimisticTransactionDB). The base DB wrapper is closed best-effort inside TransactionDB/OptimisticTransactionDB's tryClose, before the primary pointer.
  • Children-first ordering is no longer enforced by the base class; the parents are package-private, so we keep it by convention, and the parent tests cover the existing ones.

Refs #354 (a final close() with tryClose as the only virtual is a follow-up).

Test plan

  • ./mvnw test -pl core -am, ./mvnw package -pl core -am -DskipTests
  • CI on all platforms

🤖 Generated with Claude Code

doRelease, afterRelease, NativeObjectParent's final tryClose with tryCloseResource,
and NativeDBWithBaseDB's tryCloseBaseDb/tryClosePrimary hooks are gone. A parent's
own tryClose starts with releaseChildren(); NativeObjectChild.release() adds the
monitor and the unregistration around NativeObject.release(). Refs #354.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant