Skip to content
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

Rename BaseRequest#unmodifiable to copyToImmutable and add doc #2037

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gnodet
Copy link
Contributor

@gnodet gnodet commented Jan 10, 2025

No description provided.

@gnodet gnodet requested a review from elharo January 10, 2025 18:29
* @param source the source collection to create an immutable copy from
* @param <T> the type of elements in the collection
* @return an unmodifiable view of the collection, or an empty list if the input is null or empty
* @throws NullPointerException if the collection contains null elements
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we do this? In general, lists with null elements are OK, though they might be wrong in a specific case. However if null elements are wrong in the specific case I'd expect the source list to already have checked that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just a side effect of using List.copyOf(). The behavior thus surfaces to this helper methods and the javadoc mentions it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, non null elements in list are a burden. Unless there's a specific semantic associated with a null value, I'd rather forbid those. For example if you want to resolve a list of artifacts, passing null values makes absolutely no sense to me.

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 this pull request may close these issues.

2 participants