Reuse NoTransactionInContextException instances
New NoTransactionInContextException instances are created frequently in TransactionContextManager#currentContext() when there is no transaction, we could reuse the same instance instead to reduce the GC pressure. Closes gh-33601
This commit is contained in:
parent
bed3025274
commit
8e3846991d
|
@ -37,6 +37,9 @@ import org.springframework.transaction.NoTransactionException;
|
||||||
*/
|
*/
|
||||||
public abstract class TransactionContextManager {
|
public abstract class TransactionContextManager {
|
||||||
|
|
||||||
|
private static final NoTransactionInContextException NO_TRANSACTION_IN_CONTEXT_EXCEPTION =
|
||||||
|
new NoTransactionInContextException();
|
||||||
|
|
||||||
private TransactionContextManager() {
|
private TransactionContextManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +63,7 @@ public abstract class TransactionContextManager {
|
||||||
return Mono.just(holder.currentContext());
|
return Mono.just(holder.currentContext());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Mono.error(new NoTransactionInContextException());
|
return Mono.error(NO_TRANSACTION_IN_CONTEXT_EXCEPTION);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue