Repository navigation
Prevent external mutation of reference list - #1710
Conversation
jordanpadams
left a comment
There was a problem hiding this comment.
Thanks for the PR! The change itself looks good and the test covers it. One small update requested (see the inline comment on the test), plus one observation:
getReferences() doesn't appear to be called anywhere in src/ - ReferentialIntegrityUtil only uses doesReferenceExist() and addReference(). That means this hardening doesn't affect any current code path, and the method can probably be removed altogether rather than made unmodifiable. Happy to go either way, but if you agree it's unused, removing it (and this test) may be the cleaner resolution for #1618.
🤖 Generated with help from Claude Code
| class HashSetReferenceInfoTest { | ||
|
|
||
| @Test | ||
| void getReferencesReturnsUnmodifiableView() throws Exception { |
There was a problem hiding this comment.
Please replace throws Exception with the specific checked exception that can actually be thrown here. Only new URL(String) throws one, so throws java.net.MalformedURLException is enough. We avoid declaring generic Exception types.
🤖 Generated with help from Claude Code
|
Thanks for the review! I checked the repository for usages of The updated code compiles successfully with |
|



Summary
HashSetReferenceInfo.getReferences()to prevent callers from modifying the internal reference list.addReference().Testing
mvn -Dtest=HashSetReferenceInfoTest test— passed (1 test).mvn test— the full suite did not complete successfully; the Cucumber test process terminated after Windows-path URI errors and registry-related test output.Related issue
Fixes #1618