Skip to content

FINERACT-2191: ThreadLocal context handling during job execution#4501

Merged
adamsaghy merged 1 commit intoapache:developfrom
openMF:FINERACT-2191/threadLocal-context-handling-during-job-execution
Mar 27, 2025
Merged

FINERACT-2191: ThreadLocal context handling during job execution#4501
adamsaghy merged 1 commit intoapache:developfrom
openMF:FINERACT-2191/threadLocal-context-handling-during-job-execution

Conversation

@oleksii-novikov-onix
Copy link
Contributor

Description

Describe the changes made and why they were made.

Ignore if these details are present on the associated Apache Fineract JIRA ticket.

Checklist

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Write the commit message as per https://github.com/apache/fineract/#pull-requests

  • Acknowledge that we will not review PRs that are not passing the build ("green") - it is your responsibility to get a proposed PR to pass the build, not primarily the project's maintainers.

  • Create/update unit or integration tests for verifying the changes made.

  • Follow coding conventions at https://cwiki.apache.org/confluence/display/FINERACT/Coding+Conventions.

  • Add required Swagger annotation and update API documentation at fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with details of any API changes

  • Submission is not a "code dump". (Large changes can be made "in repository" via a branch. Ask on the developer mailing list for guidance, if required.)

FYI our guidelines for code reviews are at https://cwiki.apache.org/confluence/display/FINERACT/Code+Review+Guide.

@oleksii-novikov-onix oleksii-novikov-onix force-pushed the FINERACT-2191/threadLocal-context-handling-during-job-execution branch 3 times, most recently from a15738a to e933347 Compare March 26, 2025 10:08
@oleksii-novikov-onix oleksii-novikov-onix marked this pull request as ready for review March 26, 2025 10:11
String tenantIdentifier = ThreadLocalContextUtil.getTenant().getTenantIdentifier();

while (!DateUtils.isAfter(executingBusinessDate, cobBusinessDate)) {
// Need to reinitialize the thread-local tenant info because after running the job, it resets the thread
Copy link
Contributor

@adamsaghy adamsaghy Mar 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure we dont need to reinit the context once a job was executed?
The job started reset the context once finished, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need to reinitialize the context here(on while iteration level), because it's already initialized in JobStarter.run. Of course, we don’t do a full initialization using ThreadLocalContextUtil.init, but we do initialize the tenant, business date, and action context. Then, there's another initialization in InitialisationTasklet.execute. Another important change here is that we pass the tenant as a job parameter.

@oleksii-novikov-onix oleksii-novikov-onix force-pushed the FINERACT-2191/threadLocal-context-handling-during-job-execution branch from e933347 to 0d904cc Compare March 26, 2025 10:38
@oleksii-novikov-onix oleksii-novikov-onix force-pushed the FINERACT-2191/threadLocal-context-handling-during-job-execution branch from 0d904cc to e4907d1 Compare March 26, 2025 12:14
@adamsaghy adamsaghy merged commit e584e26 into apache:develop Mar 27, 2025
10 checks passed
@adamsaghy adamsaghy deleted the FINERACT-2191/threadLocal-context-handling-during-job-execution branch March 27, 2025 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants