From 01882701382220b08e392914359f9631822b5dd1 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 22 Feb 2024 16:56:17 +0100 Subject: [PATCH] Clarify transaction metadata exposed from currentTransactionStatus() Closes gh-32310 --- .../interceptor/TransactionAspectSupport.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java b/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java index 608482d9e2..08e39499b2 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java +++ b/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -153,8 +153,15 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init * Return the transaction status of the current method invocation. * Mainly intended for code that wants to set the current transaction * rollback-only but not throw an application exception. + *

This exposes the locally declared transaction boundary with its declared name + * and characteristics, as managed by the aspect. Ar runtime, the local boundary may + * participate in an outer transaction: If you need transaction metadata from such + * an outer transaction (the actual resource transaction) instead, consider using + * {@link org.springframework.transaction.support.TransactionSynchronizationManager}. * @throws NoTransactionException if the transaction info cannot be found, * because the method was invoked outside an AOP invocation context + * @see org.springframework.transaction.support.TransactionSynchronizationManager#getCurrentTransactionName() + * @see org.springframework.transaction.support.TransactionSynchronizationManager#isCurrentTransactionReadOnly() */ public static TransactionStatus currentTransactionStatus() throws NoTransactionException { TransactionInfo info = currentTransactionInfo();