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,19 +161,23 @@ public class LoanAccrualsProcessingServiceImpl implements LoanAccrualsProcessing
loans.forEach(outerLoan -> { loans.forEach(outerLoan -> {
loanTasks.add(taskExecutor.submit(() -> { loanTasks.add(taskExecutor.submit(() -> {
ThreadLocalContextUtil.init(context); try {
transactionTemplate.executeWithoutResult(status -> { ThreadLocalContextUtil.init(context);
Loan loan = loanRepositoryWrapper.findOneWithNotFoundDetection(outerLoan.getId()); transactionTemplate.executeWithoutResult(status -> {
setSetHelpers(loan); Loan loan = loanRepositoryWrapper.findOneWithNotFoundDetection(outerLoan.getId());
try { setSetHelpers(loan);
log.debug("Adding accruals for loan '{}'", loan.getId()); try {
addAccruals(loan, tillDate, false, false, true); log.debug("Adding accruals for loan '{}'", loan.getId());
log.debug("Successfully processed loan: '{}' for accrual entries", loan.getId()); addAccruals(loan, tillDate, false, false, true);
} catch (Exception e) { log.debug("Successfully processed loan: '{}' for accrual entries", loan.getId());
log.error("Failed to add accrual for loan {}", loan.getId(), e); } catch (Exception e) {
throw new RuntimeException("Failed to add accrual for loan " + loan.getId(), e); log.error("Failed to add accrual for loan {}", loan.getId(), e);
} throw new RuntimeException("Failed to add accrual for loan " + loan.getId(), e);
}); }
});
} finally {
ThreadLocalContextUtil.reset();
}
})); }));
}); });