Skip to content
Open
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
5609b3d
Add RefCounter to Env to prevent closure while in use WIP
at055612 Jan 27, 2026
2a0a6c0
Tidy code
at055612 Jan 27, 2026
81e8ae7
Change checkNotClosed to allow things to close down in CLOSING state
at055612 Jan 27, 2026
5a4585e
Fix acquire behaviour in Txn/Cursor ctors
at055612 Jan 27, 2026
a7a99c9
Add onClose to NoOpRefCounter
at055612 Jan 27, 2026
d02f01b
Tweak perf test
at055612 Jan 27, 2026
7b83648
Improve stripe hashing with golden ratio
at055612 Jan 27, 2026
301df13
Add StampedLockRefCounterImpl WIP
at055612 Jan 28, 2026
e40ee22
Add more ref counters, improve tests
at055612 Jan 29, 2026
91df336
Refactor ref counter classes
at055612 Jan 30, 2026
9f7043d
Tidy code, add tests
at055612 Jan 30, 2026
e48f1c7
Fix bug in StripedRefCounter, improve tests
at055612 Feb 2, 2026
a6080b3
Rename class
at055612 Feb 2, 2026
f9138df
Refactor test classes
at055612 Feb 2, 2026
1b84247
Improve perfTest
at055612 Feb 2, 2026
49438e9
Fix NoOpRefCounter close method
at055612 Feb 2, 2026
36019a3
Return Cursor.close() to original behavior
at055612 Feb 2, 2026
3ce28de
Fix logic in SimpleRefCounter
at055612 Feb 2, 2026
8d170c7
Improve close() method
at055612 Feb 2, 2026
4b84cf6
Remove redundant method & ctor from SimpleRefCounter
at055612 Feb 2, 2026
a6eb02b
Improve SimpleRefCounter
at055612 Feb 2, 2026
ded736e
Remove redundant EnvState
at055612 Feb 2, 2026
cb890be
Fix SimpleRefCounter.release()
at055612 Feb 2, 2026
b61dbf9
Change (Striped|Simple)RefCounter to not throw in lambda
at055612 Feb 2, 2026
e2e7d5b
Add JMH benchmark for RefCounter
at055612 Feb 2, 2026
5a5b8bf
gh-279 Fix concurrency issues in StripedRefCounter
at055612 Aug 3, 2026
37dfbdb
gh-279 Tidy code, add tests
at055612 Aug 3, 2026
519479f
gh-279 Add Env.Builder.safeClose()
at055612 Aug 4, 2026
8c9c544
gh-279 Fix tests
at055612 Aug 4, 2026
3c2f181
gh-279 Run mvn build
at055612 Aug 4, 2026
542904c
gh-279 Run mvn fmt
at055612 Aug 4, 2026
16999f0
gh-279 Change tests to use Env.safeClose
at055612 Aug 4, 2026
6e8a646
Refactor tests, rename singleThreaded builder method
at055612 Aug 10, 2026
1e19b1a
Tidy up tests
at055612 Aug 10, 2026
344d798
gh-279 Fix compilation failures under java 8
at055612 Aug 10, 2026
0831fc9
gh-279 Add test
at055612 Aug 10, 2026
ed0df73
Merge branch 'master' into gh-279-env-close-protection
at055612 Aug 10, 2026
8c001e6
gh-279 Address GH code fix suggestions
at055612 Aug 10, 2026
290522d
gh-279 Add coverage
at055612 Aug 10, 2026
cccf9dd
gh-279 Format
at055612 Aug 10, 2026
819881a
gh-279 Adding in tests written by @bernardladenthin
at055612 Aug 10, 2026
6ceea10
gh-279 Add test coverage
at055612 Aug 10, 2026
fae66ee
gh-279 Add test coverage
at055612 Aug 10, 2026
04043b5
gh-279 Fix GH suggestions
at055612 Aug 10, 2026
58f77e1
gh-279 Add test coverage
at055612 Aug 10, 2026
0729728
gh-279 Fix failing test
at055612 Aug 10, 2026
b083c29
gh-279 Fix catch in Cursor ctor
at055612 Aug 10, 2026
859c0db
gh-279 Tidy asserts in TxnTest
at055612 Aug 11, 2026
3c2ad81
gh-279 Add Env.tryClose, add more tests
at055612 Aug 11, 2026
a9228db
gh-279 Add test for Cursor ctor exception
at055612 Aug 11, 2026
2ce1c76
gh-279 Remove dead code, add test for code coverage
at055612 Aug 11, 2026
8aa99a1
gh-279 Improve Env.copy tests
at055612 Aug 11, 2026
ecf7251
Add test for KeyVal.close
at055612 Aug 11, 2026
7565c94
gh-279 Add RefCounter.run test
at055612 Aug 11, 2026
b486b76
gh-279 Fix AbstractFlagSetTest
at055612 Aug 11, 2026
c3a05d7
gh-279 Changes to AbstractFlagSetTest for codecov
at055612 Aug 11, 2026
9c7f97c
gh-279 Format
at055612 Aug 11, 2026
bfdefef
gh-279 Add tests to TargetNameTest
at055612 Aug 11, 2026
eefc87f
gh-279 Change safeClose to only track RW cursors
at055612 Aug 14, 2026
017ef34
gh-279 Add more tests, improve javadoc
at055612 Aug 14, 2026
ab0fc6a
gh-279 Fix codeQL suggestion
at055612 Aug 14, 2026
e8fdd2d
gh-279 Tweak javadoc
at055612 Aug 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve close() method
  • Loading branch information
at055612 committed Feb 2, 2026
commit 8d170c79fafee111982833dfbbdb3e82a583b26d
15 changes: 5 additions & 10 deletions src/main/java/org/lmdbjava/SimpleRefCounter.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,13 @@ public RefCounterReleaser acquire() {
public void close(final Runnable onClose) {
Objects.requireNonNull(onClose);
if (!isClosed.get()) {
final int count = getCount();
if (count == 0) {
// Set to -1 to indicate closure
if (counter.compareAndSet(count, -1)) {
if (isClosed.compareAndSet(false, true)) {
onClose.run();
}
} else {
throw new Env.EnvInUseException(getCount());
// Set to -1 to indicate closure, if the count is 0
if (counter.compareAndSet(0, -1)) {
if (isClosed.compareAndSet(false, true)) {
onClose.run();
}
} else {
throw new Env.EnvInUseException(count);
throw new Env.EnvInUseException(getCount());
}
}
}
Expand Down