marta-jankovics commented on code in PR #3649:
URL: https://github.com/apache/fineract/pull/3649#discussion_r1448097335


##########
fineract-core/src/main/java/org/apache/fineract/commands/service/SynchronousCommandProcessingService.java:
##########
@@ -92,73 +87,64 @@ public CommandProcessingResult executeCommand(final 
CommandWrapper wrapper, fina
 
         Long commandId = (Long) 
fineractRequestContextHolder.getAttribute(COMMAND_SOURCE_ID, null);
         boolean isRetry = commandId != null;
+        boolean isEnclosingTransaction = 
BatchRequestContextHolder.isEnclosingTransaction();
 
         CommandSource commandSource = null;
         String idempotencyKey;
         if (isRetry) {
             commandSource = commandSourceService.getCommandSource(commandId);
             idempotencyKey = commandSource.getIdempotencyKey();
+        } else if (command.commandId() != null) { // action on the command 
itself
+            commandId = command.commandId();
+            commandSource = commandSourceService.getCommandSource(commandId);
+            idempotencyKey = commandSource.getIdempotencyKey();
         } else {
             idempotencyKey = idempotencyKeyResolver.resolve(wrapper);
         }
         exceptionWhenTheRequestAlreadyProcessed(wrapper, idempotencyKey, 
isRetry);
 
-        boolean sameTransaction = 
BatchRequestContextHolder.getEnclosingTransaction().isPresent();
+        AppUser user = context.authenticatedUser(wrapper);
         if (commandSource == null) {
-            AppUser user = context.authenticatedUser(wrapper);
-            if (sameTransaction) {
-                commandSource = 
commandSourceService.getInitialCommandSource(wrapper, command, user, 
idempotencyKey);
-            } else {
-                commandSource = 
commandSourceService.saveInitialNewTransaction(wrapper, command, user, 
idempotencyKey);

Review Comment:
   Any other call would fail, because the idempotency key is unique, but not 
with 'Too early' error, which would be the correct error code in this case.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to