Visitar URL original
[java-firestore] Clarify QueryPartition cursor array mutability · Issue #14762 · googleapis/google-cloud-java · GitHub
Skip to content

[java-firestore] Clarify QueryPartition cursor array mutability #14762

Open

Description

@pallasivasai

While exploring the Firestore client code, I noticed that QueryPartition stores the startAt and endBefore arrays passed to its constructor and returns those arrays directly from getStartAt() and getEndBefore().

Source: https://github.com/googleapis/google-cloud-java/blob/main/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/QueryPartition.java

Because Java arrays are mutable, a caller can potentially change the cursor boundaries after a QueryPartition is constructed or after a getter returns them. Those boundaries are then used by createQuery(), equals(), and hashCode().

I have not confirmed whether this behavior is intentional, so I am opening this issue to ask for guidance rather than proposing a code change as a confirmed fix.

Question / Expected behavior

Is QueryPartition intended to expose mutable cursor arrays, or should it preserve its cursor boundaries from external mutation?

If immutable boundary state is intended, would defensive copies in the constructor and getters, with unit tests, be an appropriate approach? I would appreciate confirmation before preparing a change.

First-time contributor note

Hello maintainers,

I am new to contributing to this repository and am learning the codebase and contribution guidelines. Please let me know if I have misunderstood the intended behavior, if this is not a valid issue, or if there is an existing discussion I missed. Feedback on how I can improve this report would help me avoid repeating mistakes in future contributions.

I have not made any code changes yet. Thank you for your time and guidance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions