FINERACT-2181: Added threadlocal context reset during parallel accrual processing

This commit is contained in:
Arnold Galovics
2025-03-26 13:24:32 +01:00
committed by Arnold Gálovics
parent 961e6d1aa6
commit 134b097a5e
@@ -161,6 +161,7 @@ public class LoanAccrualsProcessingServiceImpl implements LoanAccrualsProcessing
loans.forEach(outerLoan -> { loans.forEach(outerLoan -> {
loanTasks.add(taskExecutor.submit(() -> { loanTasks.add(taskExecutor.submit(() -> {
try {
ThreadLocalContextUtil.init(context); ThreadLocalContextUtil.init(context);
transactionTemplate.executeWithoutResult(status -> { transactionTemplate.executeWithoutResult(status -> {
Loan loan = loanRepositoryWrapper.findOneWithNotFoundDetection(outerLoan.getId()); Loan loan = loanRepositoryWrapper.findOneWithNotFoundDetection(outerLoan.getId());
@@ -174,6 +175,9 @@ public class LoanAccrualsProcessingServiceImpl implements LoanAccrualsProcessing
throw new RuntimeException("Failed to add accrual for loan " + loan.getId(), e); throw new RuntimeException("Failed to add accrual for loan " + loan.getId(), e);
} }
}); });
} finally {
ThreadLocalContextUtil.reset();
}
})); }));
}); });