Skip to content

fix(settings): return defaults after repairing malformed settings (#481) - #487

Merged
jvondermarck merged 4 commits into
jvondermarck:mainfrom
AzazelSensei:fix-481-settings-malformed-null
Sep 15, 2026
Merged

jvondermarck merged 4 commits into
jvondermarck:mainfrom
AzazelSensei:fix-481-settings-malformed-null

Conversation

@AzazelSensei

Copy link
Copy Markdown
Contributor

✅ PR Checklist

  • My PR title follows the format: type(scope): description (#issue) (scope and #issue optional)
  • I used the correct type: feat, fix, refactor, docs, test, chore
  • I reviewed my code and removed unnecessary debug logs or comments.
  • I tested my changes and verified they work as expected.
  • I ran the project to confirm it compiles and runs correctly.
  • I read the Code of Conduct and the Contribution Guidelines.

📝 What does this PR do?

  • Return the regenerated default settings from SettingsProvider.loadSettings() when a stored value is invalid, instead of falling through to null.
  • Add a regression test that writes soundVolume=not-a-number and checks the first call comes back with defaults and a valid file.

🔗 Related Issue

📸 Screenshots / Demos (if applicable)

Note

🦖 No screenshots or demo provided.

💬 Extra Notes (Optional)

I ran mvn -B -Dtest=SettingsProviderTest test on the malformed file from the issue. It failed on main and passed on this branch.

loadSettings() deleted a bad settings.properties file and reloaded it,
but dropped the recursive result and returned null. Return the repaired
defaults instead.

Fixes jvondermarck#481
@vercel

vercel Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
dinosaur-exploder Ignored Ignored Preview Sep 15, 2026 8:08pm UTC

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👋 Hello @AzazelSensei, thank you for submitting in Dinosaur Exploder 🦖 PR! To allow your work to be integrated as seamlessly as possible, we advise you to:

  • ✅ Verify your PR is up-to-date with the repository /dinosaur-exploder main branch. If your PR is behind you can update your code by clicking the 'Update branch' button or by running git pull and git merge master locally.
  • ✅ Verify all Dinosaur Exploder Continuous Integration (CI) checks are passing.
  • ✅ Verify that you have well fill out the different checkboxes in the PR template.
  • ⚠️ Check that your code is clean: no code redundancy, variable and method names are correct, your code is understandable to everyone, and so on.
  • 💡 Reduce changes to the absolute minimum required for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." — Bruce Lee

@dinoexploderbot

Copy link
Copy Markdown

✅ Code Formatting Check Passed!

badge

Great job! 🎉 Your code follows the Google Java Style Guide.


🤖 The DinoBot Team 🦖

@github-actions

github-actions Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Build preview 🚀

badge

Thanks for your contribution to this open-source project! ❤️

A new build has been generated for this pull request:

  • 🎮 Game Artifacts: 🐧 Linux / 🍎 macOS / 🪟 Windows
  • 🧪 Workflow Run: View Logs
  • 🔖 Commit: 63fb0f9333d22bc63e940a8bdb49e1f62d19b0ed

Tip

This JAR lets you test the latest version of the game from this PR.

⏳ Note: Artifacts auto-expire after ~90 days.

Happy testing & enjoy the game! 🎮

The DinoBot Team 🦖

@jvondermarck jvondermarck left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Looks good for me, thanks for the unit test!
Just please read my comment and if you have time and want, feel free to improve the whole file according to what I said. Thanks :)

@jvondermarck jvondermarck added status: help-wanted Extra attention is needed type: question Further information is requested status: in-review PR currently in review labels Sep 10, 2026
Read, parse, and restore-defaults each live in their own method so
the two nested try/catch blocks are gone.
@jvondermarck

Copy link
Copy Markdown
Owner

readSettingsFile no longer returns null when the file is missing
or unreadable. Sonar java:S1168 flagged both paths.
@AzazelSensei

Copy link
Copy Markdown
Contributor Author

Fixed the two Sonar S1168 findings. readSettingsFile now returns an empty Properties instead of null when the file is missing or unreadable.

@jvondermarck

Copy link
Copy Markdown
Owner

Uh shit I merged another PR in the meantime and the guy changed this file, could you please git pull main (inside the mainbranch) and git merge main in your fix-481-settings-malformed-null branch? Sorry @AzazelSensei

Keep the malformed-settings fix and pick up updateMuteState from jvondermarck#489.
@AzazelSensei

Copy link
Copy Markdown
Contributor Author

Merged main into this branch. Kept the malformed-settings fix and brought in updateMuteState from the other PR.

@sonarqubecloud

Copy link
Copy Markdown

@jvondermarck

Copy link
Copy Markdown
Owner

Amazing, you rock! @AzazelSensei Thanks !! Please make sure to "Star" the project and if you have any ideas on new features on the game or whatever, please create new issues. goal here is to not let the project die

@jvondermarck
jvondermarck merged commit d0fef65 into jvondermarck:main Sep 15, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: help-wanted Extra attention is needed status: in-review PR currently in review type: question Further information is requested

Projects

Development

Successfully merging this pull request may close these issues.

[Bug]: SettingsProvider returns null after repairing malformed settings

2 participants