Skip to content

Bug: HashSetReferenceInfo.getReferences() exposes live mutable ArrayList from shared static state #1618

Description

@jordanpadams

Summary

HashSetReferenceInfo.getReferences() returns the live backing ArrayList<String> directly. Callers can add, remove, or clear entries without going through addReference(). Because HashSetReferenceInfo objects are stored as values in the static HashMaps in ReferentialIntegrityUtil (e.g. contextReferencesCumulative, bundleReferenceMap, collectionReferenceMap), external mutation of a returned list corrupts shared static validation state silently.

Affected code

gov/nasa/pds/tools/util/HashSetReferenceInfo.java, getReferences() (~line 55):

public ArrayList<String> getReferences() {
    return (this.references);
}

Recommended fix

Change return type to List<String> and return Collections.unmodifiableList(this.references). Mutation should only occur through addReference().

Related

Identified during immutability/synchronization audit triggered by PR #1607 review feedback.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcleanup

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    ToDo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions