Skip to content

Commit 48b5d93

Browse files
committed
minor refactoring
1 parent 2af5265 commit 48b5d93

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

environment/src/main/java/jetbrains/exodus/env/ContextualEnvironmentImpl.java

+6-7
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,15 @@ private void setCurrentTransaction(@NotNull final TransactionBase result) {
175175

176176
@Override
177177
protected void finishTransaction(@NotNull final TransactionBase txn) {
178-
finishTransactionSafe(txn, true);
178+
final Thread thread = txn.getCreatingThread();
179+
if (!Thread.currentThread().equals(thread)) {
180+
throw new ExodusException("Can't finish transaction in a thread different from the one which it was created in");
181+
}
182+
finishTransactionUnsafe(txn);
179183
}
180184

181-
void finishTransactionSafe(@NotNull final TransactionBase txn, boolean checkThread) {
185+
void finishTransactionUnsafe(@NotNull final TransactionBase txn) {
182186
final Thread thread = txn.getCreatingThread();
183-
if (checkThread) {
184-
if (!Thread.currentThread().equals(thread)) {
185-
throw new ExodusException("Can't finish transaction in a thread different from the one which it was created in");
186-
}
187-
}
188187
final Deque<TransactionBase> stack = threadTxns.get(thread);
189188
if (stack == null) {
190189
throw new ExodusException("Transaction was already finished");

environment/src/main/kotlin/jetbrains/exodus/env/StuckTransactionMonitor.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ internal class StuckTransactionMonitor(env: EnvironmentImpl) : Job() {
5757
}
5858
env.transactionExpirationTimeout().forEachExpiredTransaction { txn ->
5959
if (env is ContextualEnvironmentImpl) {
60-
env.finishTransactionSafe(txn, false)
60+
env.finishTransactionUnsafe(txn)
6161
} else {
6262
env.finishTransaction(txn)
6363
}

0 commit comments

Comments
 (0)