File tree Expand file tree Collapse file tree
fineract-core/src/main/java/org/apache/fineract/commands/service Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,12 +30,28 @@ public class IdempotencyKeyResolver {
3030
3131 private final FineractRequestContextHolder fineractRequestContextHolder ;
3232
33+ private final DeterministicIdempotencyKeyGenerator deterministicGenerator ;
34+
3335 private final IdempotencyKeyGenerator idempotencyKeyGenerator ;
3436
3537 public String resolve (CommandWrapper wrapper ) {
36- return Optional .ofNullable (wrapper .getIdempotencyKey ()).orElseGet (() -> getAttribute ().orElseGet (idempotencyKeyGenerator ::create ));
38+
39+ // If wrapper already has key → use it
40+ if (wrapper .getIdempotencyKey () != null ) {
41+ return wrapper .getIdempotencyKey ();
42+ }
43+
44+ // If request attribute exists (internal retry)
45+ Optional <String > attributeKey = getAttribute ();
46+ if (attributeKey .isPresent ()) {
47+ return attributeKey .get ();
48+ }
49+
50+ // hybrid logic (external retry)
51+ return deterministicGenerator .generate (wrapper );
3752 }
3853
54+
3955 private Optional <String > getAttribute () {
4056 return Optional .ofNullable (fineractRequestContextHolder .getAttribute (SynchronousCommandProcessingService .IDEMPOTENCY_KEY_ATTRIBUTE ))
4157 .map (String ::valueOf );
You can’t perform that action at this time.
0 commit comments