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

Actually don't check SingletonList as comment says. #1132

Merged
merged 3 commits into from
Apr 1, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Clarify why we don't check type of singleton list
  • Loading branch information
anuraaga committed Mar 31, 2020
commit 74ae94b58be6a8a8e0c98696934db62a616d5285
4 changes: 3 additions & 1 deletion brave/src/main/java/brave/internal/Lists.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ public static List<Object> ensureImmutable(List<Object> list) {
}

static boolean isImmutable(List<Object> extra) {
if (extra == Collections.emptyList()) return true;
assert extra.size() > 1; // Handled by caller.
// avoid copying datastructure by trusting certain names.
String simpleName = extra.getClass().getSimpleName();
// We don't need to check EMPTY_LIST or SingletonList here since our only caller handles them
// without type-checking.
return simpleName.startsWith("Unmodifiable")
|| simpleName.contains("Immutable");
}
Expand Down