This is an automated email from the ASF dual-hosted git repository.
adamsaghy pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git
The following commit(s) were added to refs/heads/develop by this push:
new ae8ad4b68 FINERACT-1724 - Transaction handling fix - [x] Fix Fetch new
transaction
ae8ad4b68 is described below
commit ae8ad4b6891e7575654e010028aff280e77a5e09
Author: Janos Haber <[email protected]>
AuthorDate: Mon Mar 27 22:27:47 2023 +0200
FINERACT-1724 - Transaction handling fix
- [x] Fix Fetch new transaction
---
.../fineract/commands/service/CommandSourceService.java | 6 ------
.../service/SynchronousCommandProcessingService.java | 14 ++------------
2 files changed, 2 insertions(+), 18 deletions(-)
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandSourceService.java
b/fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandSourceService.java
index 09406ce1b..39420ec1a 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandSourceService.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandSourceService.java
@@ -89,17 +89,11 @@ public class CommandSourceService {
}
}
- @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true)
public CommandSource findCommandSource(CommandWrapper wrapper, String
idempotencyKey) {
return
commandSourceRepository.findByActionNameAndEntityNameAndIdempotencyKey(wrapper.actionName(),
wrapper.entityName(),
idempotencyKey);
}
- public CommandSource findCommandSourceNoTransaction(CommandWrapper
wrapper, String idempotencyKey) {
- return
commandSourceRepository.findByActionNameAndEntityNameAndIdempotencyKey(wrapper.actionName(),
wrapper.entityName(),
- idempotencyKey);
- }
-
private CommandSource getInitialCommandSource(CommandWrapper wrapper,
JsonCommand jsonCommand, AppUser maker, String idempotencyKey) {
CommandSource commandSourceResult;
if (jsonCommand.commandId() != null) {
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/commands/service/SynchronousCommandProcessingService.java
b/fineract-provider/src/main/java/org/apache/fineract/commands/service/SynchronousCommandProcessingService.java
index 899e3b84d..233a2639d 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/commands/service/SynchronousCommandProcessingService.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/commands/service/SynchronousCommandProcessingService.java
@@ -109,22 +109,12 @@ public class SynchronousCommandProcessingService
implements CommandProcessingSer
try {
result = findCommandHandler(wrapper).processCommand(command);
} catch (Throwable t) { // NOSONAR
- CommandSource source;
- if
(BatchRequestContextHolder.getEnclosingTransaction().isPresent()) {
- source =
commandSourceService.findCommandSourceNoTransaction(wrapper, idempotencyKey);
- } else {
- source = commandSourceService.findCommandSource(wrapper,
idempotencyKey);
- }
+ CommandSource source =
commandSourceService.findCommandSource(wrapper, idempotencyKey);
commandSourceService.saveFailed(source);
publishHookErrorEvent(wrapper, command, t);
throw t;
}
- CommandSource initialCommandSource;
- if (BatchRequestContextHolder.getEnclosingTransaction().isPresent()) {
- initialCommandSource =
commandSourceService.findCommandSourceNoTransaction(wrapper, idempotencyKey);
- } else {
- initialCommandSource =
commandSourceService.findCommandSource(wrapper, idempotencyKey);
- }
+ CommandSource initialCommandSource =
commandSourceService.findCommandSource(wrapper, idempotencyKey);
initialCommandSource.setResult(toApiJsonSerializer.serializeResult(result));
initialCommandSource.updateResourceId(result.getResourceId());