-
Notifications
You must be signed in to change notification settings - Fork 4
STDO-124: Fix NPE and test-isolation failures #33
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| **RESUME STATE** *(top of the file; rewritten in place, never appended to; keep under 12 lines)* | ||
| - **Reconciled at**: this branch's HEAD, the P4 build-verification fix commit. | ||
| - **Authoritative**: `PLAN.md` in `lucidworks/tbe-pitches`, branch `STDO-124-bet`, for stage | ||
| sequencing, the done-condition, the stage graph and every measured claim. This file exists only | ||
| so `/team-studios:status` and the compaction resume hook have something to find in this repo. | ||
| - **Next**: this repo's release cut (an actual version tag) is a human action, not part of P4's | ||
| done-condition. | ||
|
|
||
| **Decisions** *(append-only)* | ||
| - **This file is a pointer, not a fork of the plan.** Full decision log: `tbe-pitches`'s | ||
| `decision-log.md` on `STDO-124-bet`. | ||
| - **Two real defects fixed, not worked around**, to get a clean `mvn clean package` from an empty | ||
| local repository: a `NullPointerException` in `PropertiesLoader.readFolder` on a `null` | ||
| `listFiles()` result, and four test failures caused by a process-wide `Fig` singleton left | ||
| mutated by `FigUtilsTest` with no teardown. | ||
|
|
||
| **Wiki candidates** *(append during the work, not at the end)* | ||
| - (empty) | ||
|
|
||
| --- | ||
|
|
||
| resume-state template r3-tamarind |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| package twigkit.fig.util; | ||
|
|
||
| import org.junit.After; | ||
| import org.junit.Test; | ||
| import twigkit.fig.Config; | ||
| import twigkit.fig.Fig; | ||
|
|
@@ -13,9 +14,27 @@ | |
| */ | ||
| public class FigUtilsTest { | ||
|
|
||
| /** | ||
| * {@link Fig#getInstance(twigkit.fig.loader.Loader...)} returns a process-wide singleton | ||
| * keyed on the loader(s) used. {@link FigUtils#merge(Fig, Fig)} mutates its first | ||
| * argument in place, so merging into the singleton for "confs" here would otherwise | ||
| * permanently leave that shared instance with merged-in data for the rest of the test | ||
| * run, corrupting unrelated tests (e.g. in {@code MergedPropertiesLoaderTest}) that | ||
| * expect to see the pristine "confs" configuration. Reloading after each test restores | ||
| * the singleton to its original, unmerged state. | ||
| */ | ||
| private Fig primary; | ||
|
|
||
| @After | ||
| public void restoreSharedPrimaryFig() { | ||
| if (primary != null) { | ||
| primary.reload(); | ||
| } | ||
| } | ||
|
Comment on lines
+17
to
+33
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P3 — medium] Singleton-isolation fix has no automated test proving it prevents the cross-class failure it targetsBy inspection this teardown is correct: Tip Suggested: add a combined-suite test (or 💡 Copy this prompt to fix with Claude Code |
||
|
|
||
| @Test | ||
| public void testExistingConfigPropertiesAreLeftUnchanged() { | ||
| Fig primary = Fig.getInstance(new PropertiesLoader("confs")); | ||
| primary = Fig.getInstance(new PropertiesLoader("confs")); | ||
| Fig secondary = Fig.getInstance(new PropertiesLoader("confs_dev")); | ||
|
|
||
| String originalRoot1KeyValue = primary.find("root").value("root-1-key").as_string(); | ||
|
|
@@ -38,7 +57,7 @@ public void testExistingConfigPropertiesAreLeftUnchanged() { | |
|
|
||
| @Test | ||
| public void testExistingConfigsAreUpdatedWithNewPropertyValues() { | ||
| Fig primary = Fig.getInstance(new PropertiesLoader("confs")); | ||
| primary = Fig.getInstance(new PropertiesLoader("confs")); | ||
| Fig secondary = Fig.getInstance(new PropertiesLoader("confs_dev")); | ||
|
|
||
| FigUtils.merge(primary, secondary); | ||
|
|
@@ -55,7 +74,7 @@ public void testExistingConfigsAreUpdatedWithNewPropertyValues() { | |
|
|
||
| @Test | ||
| public void testExistingConfigsAreUpdatedWithNewProperties() { | ||
| Fig primary = Fig.getInstance(new PropertiesLoader("confs")); | ||
| primary = Fig.getInstance(new PropertiesLoader("confs")); | ||
| Fig secondary = Fig.getInstance(new PropertiesLoader("confs_dev")); | ||
|
|
||
| FigUtils.merge(primary, secondary); | ||
|
|
@@ -70,7 +89,7 @@ public void testExistingConfigsAreUpdatedWithNewProperties() { | |
|
|
||
| @Test | ||
| public void testExistingConfigsAreUpdatedWithNewExtensions() { | ||
| Fig primary = Fig.getInstance(new PropertiesLoader("confs")); | ||
| primary = Fig.getInstance(new PropertiesLoader("confs")); | ||
| Fig secondary = Fig.getInstance(new PropertiesLoader("confs_dev")); | ||
|
|
||
| FigUtils.merge(primary, secondary); | ||
|
|
@@ -81,7 +100,7 @@ public void testExistingConfigsAreUpdatedWithNewExtensions() { | |
|
|
||
| @Test | ||
| public void testNewConfigsCanBeAdded() { | ||
| Fig primary = Fig.getInstance(new PropertiesLoader("confs")); | ||
| primary = Fig.getInstance(new PropertiesLoader("confs")); | ||
| Fig secondary = Fig.getInstance(new PropertiesLoader("confs_dev")); | ||
|
|
||
| FigUtils.merge(primary, secondary); | ||
|
|
@@ -92,7 +111,7 @@ public void testNewConfigsCanBeAdded() { | |
|
|
||
| @Test | ||
| public void testChildConfigPropertyValuesCanBeUpdated() { | ||
| Fig primary = Fig.getInstance(new PropertiesLoader("confs")); | ||
| primary = Fig.getInstance(new PropertiesLoader("confs")); | ||
| Fig secondary = Fig.getInstance(new PropertiesLoader("confs_dev")); | ||
|
|
||
| FigUtils.merge(primary, secondary); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2 — high] New null-guard branches for
folder.listFiles()have no regression test anywhere in the repoNeither new null-guard branch (lines 93-97 for the file-listing call, lines 129-132 for the nested-folder-listing call) is exercised by any test.
fig-core/pom.xmlhas no Mockito/EasyMock/PowerMock or similar mocking dependency, and every existing test inPropertiesLoaderTest.java/MergedPropertiesLoaderTest.javapasses an already-confirmed real directory intoreadFolder, solistFiles()never returnsnullin the current test suite.Tip
Suggested: add a unit test that points a
PropertiesLoaderat aFilethat is not a directory (solistFiles()returnsnullper thejava.io.Filecontract) and assertreadFolder/loadcompletes without throwing. This is the cheapest way to hit the guard without adding a mocking library dependency.💡 Copy this prompt to fix with Claude Code