Skip to content

Fix for Exposing internal representation#1298

Closed
derTobsch wants to merge 1 commit into
mainfrom
finding-autofix-4
Closed

Fix for Exposing internal representation#1298
derTobsch wants to merge 1 commit into
mainfrom
finding-autofix-4

Conversation

@derTobsch

Copy link
Copy Markdown
Contributor

Use defensive copying and return an unmodifiable view/copy from the getter.

Best fix without changing intended functionality:

  • In setChildren(...), copy incoming map into a new HashMap instead of storing the passed reference.
  • In getChildren(), return an unmodifiable map (preferably an unmodifiable copy) so callers cannot mutate internal state.
  • Add needed import for Collections.

Edits are all in:

  • jollyday-core/src/main/java/de/focus_shift/jollyday/core/CalendarHierarchy.java
    • imports section
    • setChildren(...)
    • getChildren()

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Tobias Schneider <Tobias.Schneider@Tobsch.org>
@derTobsch derTobsch closed this Jun 15, 2026
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.

1 participant