Skip to content

Documentation is wrong about immutability #965

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DarioViva42 opened this issue Sep 2, 2024 · 1 comment · Fixed by #974
Closed

Documentation is wrong about immutability #965

DarioViva42 opened this issue Sep 2, 2024 · 1 comment · Fixed by #974
Milestone

Comments

@DarioViva42
Copy link

DarioViva42 commented Sep 2, 2024

public static <T> Set<T> asSet(Collection<T> c) {

You tell users, that asSet returns an immutable Set.

@return a type-safe immutable {@code Set} containing the specified collection elements.

This is not true, when you pass in a mutable Set. In this case the Collection is only cast to a Set. You probably want to change the documentation or use java.util.Collections.unmodifiableSet

@lhazlewood
Copy link
Contributor

@DarioViva42 sorry for the delay on this! I'm not sure why we didn't see it until recently. Thanks for the PR!

@lhazlewood lhazlewood added this to the 0.12.7 milestone Apr 23, 2025
lhazlewood pushed a commit that referenced this issue Apr 23, 2025
* Return immutable Set for a Collection

Fixes #965
lhazlewood added a commit that referenced this issue Apr 23, 2025
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 a pull request may close this issue.

2 participants