Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FM2-651: Allow DAOs access to all API load-able by the OpenMRS Class loader. #554

Merged
merged 3 commits into from
Dec 13, 2024

Conversation

Ruhanga
Copy link
Member

@Ruhanga Ruhanga commented Dec 11, 2024

Description of what I changed

Issue I worked on

see https://openmrs.atlassian.net/browse/FM2-651

Checklist: I completed these to help reviewers :)

  • My IDE is configured to follow the code style of this project.
  • I have added tests to cover my changes. (If you refactored
    existing code that was well tested you do not have to add tests)
  • I ran mvn clean package right before creating this pull request and
    added all formatting changes to my commit.
  • All new and existing tests passed.
  • My pull request is based on the latest changes of the master branch.

@ibacher
Copy link
Member

ibacher commented Dec 11, 2024

So, a couple of things here:

  1. For FHIR module PRs we usually want to have tests so we don't regress on the issue
  2. Doing this in the DAO layer feels off to me; it would be preferable to do it somewhere centrally, maybe in the servlet itself, e.g., overwriting the service() method to something like Thread.currentThread().setContextClassLoader(OpenmrsClassLoader.getInstance()); super().
  3. Have you tried this and does this actually fix the issue? The reason I ask is that the getSearchResultsCount() method is called before getSearchResults() and I'd expect we'd need to the same fix for createOrUpdate() and delete() as well.

@Ruhanga
Copy link
Member Author

Ruhanga commented Dec 12, 2024

Have you tried this and does this actually fix the issue?

Yes.

Doing this in the DAO layer feels off to me; it would be preferable to do it somewhere centrally, maybe in the servlet itself, e.g., overwriting the service() method to something like Thread.currentThread().setContextClassLoader(OpenmrsClassLoader.getInstance()); super().

I initially wanted to ensure that the ContextClassLoader was set correctly when the DAO layer was called. However, after reconsidering, I realized this wasn’t strictly necessary. As a result, I’ve implemented the suggested approach, which works just as well.

@Ruhanga Ruhanga requested a review from ibacher December 12, 2024 08:32
@ibacher ibacher merged commit 46e3b96 into openmrs:master Dec 13, 2024
1 of 2 checks passed
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