Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception thrown by TransactionSynchronization#afterCompletion is eaten and there is no way to catch and perform any operation [SPR-12560] #17162

Closed
spring-projects-issues opened this issue Dec 19, 2014 · 7 comments
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) status: superseded An issue that has been superseded by another

Comments

@spring-projects-issues
Copy link
Collaborator

Mohammad opened SPR-12560 and commented

Exception thrown in TransactionSynchronization's afterComplete method doesn't be propagated back to calling method. Reason is org.springframework.transaction.support.TransactionSynchronizationUtils class invokeAfterCompletion has below implementation -

public static void invokeAfterCompletion(List<TransactionSynchronization> synchronizations, int completionStatus) {
if (synchronizations != null) {
for (TransactionSynchronization synchronization : synchronizations) {
try {
synchronization.afterCompletion(completionStatus);
}
catch (Throwable tsex) {
logger.error("TransactionSynchronization.afterCompletion threw exception", tsex);
}
}
}
}

Since it is calling multiple synchronizer in a row hence they are eating exception and just logging it(which is clearly written as java doc). I think there should be a way to throw exception so that if required client code can perform some operation.

One solution would be to run afterComplete method in different threads and propagate exceptions with that thread. For programmatic transaction management, we would get know exception (Considering declarative transaction interceptors would not help as control won't come to client code)

Reference question in stackoverflow is - http://stackoverflow.com/questions/27563561/transactionsynchronization-sallow-runtimeexception-that-is-thrown-while-aftercom?noredirect=1#comment43558721_27563561


Affects: 4.0.3

@spring-projects-issues
Copy link
Collaborator Author

Mohammad commented

do we have any resolution date?

@spring-projects-issues spring-projects-issues added status: waiting-for-triage An issue we've not yet triaged or decided on in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement and removed type: enhancement A general enhancement labels Jan 11, 2019
@rstoyanchev rstoyanchev added status: bulk-closed An outdated, unresolved issue that's closed in bulk as part of a cleaning process and removed status: bulk-closed An outdated, unresolved issue that's closed in bulk as part of a cleaning process status: waiting-for-triage An issue we've not yet triaged or decided on labels Jan 11, 2019
@spring-projects-issues
Copy link
Collaborator Author

Bulk closing outdated, unresolved issues. Please, reopen if still relevant.

@slinstaedt
Copy link

Yep, still relevant. Only issue is logging level had been decreased to debug, so devs won't even recognised, something went wrong, because in most setup's will filter debug level log messages.

@sbrannen
Copy link
Member

sbrannen commented Jun 1, 2022

@slinstaedt, with which Spring Framework version(s) are you experiencing this?

@slinstaedt
Copy link

org.springframework:spring-tx:jar:5.3.18 which should be part of spring boot 2.5.12.

@KSH-code
Copy link
Contributor

@bclozel
Copy link
Member

bclozel commented Jul 14, 2023

Thanks @KSH-code !

While the original issue was more about making that exception available through a callback of some sort, the reason for reopening it is indeed about the logging level.

Closing this issue as a superseded by #30776

@bclozel bclozel added status: superseded An issue that has been superseded by another and removed status: bulk-closed An outdated, unresolved issue that's closed in bulk as part of a cleaning process labels Jul 14, 2023
@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) status: superseded An issue that has been superseded by another
Projects
None yet
Development

No branches or pull requests

6 participants