Skip to content

TRUNK-6637: Restore runtime properties after InitializationFilterE2ETest#6112

Open
solomonfortune wants to merge 1 commit into
openmrs:masterfrom
solomonfortune:TRUNK-6637-fix-e2e-runtime-properties-leak
Open

TRUNK-6637: Restore runtime properties after InitializationFilterE2ETest#6112
solomonfortune wants to merge 1 commit into
openmrs:masterfrom
solomonfortune:TRUNK-6637-fix-e2e-runtime-properties-leak

Conversation

@solomonfortune
Copy link
Copy Markdown

Description of what I changed

In InitializationFilterE2ETest.setup(), the @BeforeEach method called Context.setRuntimeProperties(new Properties()) but never restored the original value. The empty Properties instance leaked into subsequent test classes in the same Surefire fork that triggered a Spring ApplicationContext load, causing SchedulerConfig/JobRunrConfig to build a DataSource with no URL or credentials. H2 then rejected the connection with Wrong user name or password [28000-232], poisoning the cached context for all remaining tests.

Fixed by saving Context.getRuntimeProperties() before clearing it in @BeforeEach, and restoring it in @AfterEach. This preserves the test's ability to assert behaviour when runtime properties are absent, without leaking the empty state to other tests.

Issue I worked on

see https://issues.openmrs.org/browse/TRUNK-6637

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.

Copy link
Copy Markdown
Contributor

@jwnasambu jwnasambu left a comment

Choose a reason for hiding this comment

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

@solomonfortune Thanks for this fix. Would you mind resolving the merge conflicts as well? Also, please run mvn spotless:apply to fix the formatting issues.

@solomonfortune
Copy link
Copy Markdown
Author

@solomonfortune Thanks for this fix. Would you mind resolving the merge conflicts as well? Also, please run mvn spotless:apply to fix the formatting issues.

okay let me work on that as soon as possible

@solomonfortune solomonfortune force-pushed the TRUNK-6637-fix-e2e-runtime-properties-leak branch from 8af2ccf to b7239df Compare May 21, 2026 07:15
@sonarqubecloud
Copy link
Copy Markdown

@solomonfortune
Copy link
Copy Markdown
Author

Screenshot (354) @jwnasambu the mvn spotless:apply built successfully and the merge conflits have also been resolved

@dkayiwa
Copy link
Copy Markdown
Member

dkayiwa commented May 21, 2026

@solomonfortune are all changes in this pull request required for the fix?

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.45%. Comparing base (d3a80d1) to head (b7239df).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6112      +/-   ##
============================================
+ Coverage     59.38%   59.45%   +0.06%     
- Complexity     9242     9245       +3     
============================================
  Files           693      693              
  Lines         37254    37254              
  Branches       5485     5485              
============================================
+ Hits          22123    22149      +26     
+ Misses        13138    13118      -20     
+ Partials       1993     1987       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@jwnasambu jwnasambu left a comment

Choose a reason for hiding this comment

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

@coderabbitai review

@dkayiwa
Copy link
Copy Markdown
Member

dkayiwa commented May 21, 2026

@coderabbitai fullreview

@dkayiwa
Copy link
Copy Markdown
Member

dkayiwa commented May 24, 2026

@solomonfortune are all changes in this pull request required for the fix?

@solomonfortune
Copy link
Copy Markdown
Author

solomonfortune commented May 24, 2026

@solomonfortune are all changes in this pull request required for the fix?

@dkayiwa

The only changes strictly required for the fix are:

  1. Adding the savedRuntimeProperties field
  2. Saving Context.getRuntimeProperties() before clearing it in setup()
  3. Restoring it via Context.setRuntimeProperties(savedRuntimeProperties) in cleanup()

i thihnk the remaining changes are reformatting applied by mvn spotless:apply to bring the file in line with the project's code style. I ran spotless as requested by @jwnasambu. If you prefer a minimal diff without the formatting changes, I'm happy to revert the formatting and keep only the functional fix.

@dkayiwa
Copy link
Copy Markdown
Member

dkayiwa commented May 24, 2026

@solomonfortune did you get a chance to look at this? https://opensource.com/article/18/6/anatomy-perfect-pull-request

@solomonfortune
Copy link
Copy Markdown
Author

@solomonfortune did you get a chance to look at this? https://opensource.com/article/18/6/anatomy-perfect-pull-request

@dkayiwa I have really never. Let me take the opportunity to look at it right now

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.

4 participants