- Notifications
You must be signed in to change notification settings - Fork26
Protect event tags from external mutation#267
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
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.
Pull Request Overview
This PR protects theGenericEvent class from external mutation by implementing defensive copying and immutable views of tag collections. The changes prevent external code from directly modifying an event's tags after creation or retrieval.
- Implements defensive copying in constructors and setter methods to prevent shared mutable state
- Exposes tags through an unmodifiable view to prevent external modification
- Updates test cases to work with the new immutable tag access pattern
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| GenericEvent.java | Adds defensive copying in constructor and setTags method, implements unmodifiable tag getter |
| ZapRequestEventValidateTest.java | Updates tests to create tag copies before modification since direct tag mutation is no longer possible |
| } | ||
| } | ||
| publicList<BaseTag>getTags() { |
CopilotAIAug 10, 2025
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.
Adding a new public getTags() method could be a breaking change if this method already exists in the class or its parent classes. Verify that this doesn't override an existing method with different behavior.
| publicList<BaseTag>getTags() { | |
| publicList<BaseTag>getBaseTags() { |
0895c09 intodevelopUh oh!
There was an error while loading.Please reload this page.
Summary
GenericEventconstructors andsetTagsTesting
mvn -q verify(fails: Coverage checks have not been met for nostr-java-encryption)mvn -q -pl nostr-java-event -am testhttps://chatgpt.com/codex/tasks/task_b_6898e475555c833192749c48a74b0281