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

Fixes problem with null-keys in LinkedHashMap put() and remove() #1597

Merged
merged 1 commit into from
Oct 1, 2016
Merged

Fixes problem with null-keys in LinkedHashMap put() and remove() #1597

merged 1 commit into from
Oct 1, 2016

Conversation

danieldietrich
Copy link
Contributor

No description provided.

@danieldietrich danieldietrich added this to the 2.0.4 milestone Oct 1, 2016
@@ -427,7 +427,7 @@ public boolean isEmpty() {
Queue<Tuple2<K, V>> newList = list;
HashMap<K, V> newMap = map;
if (containsKey(key)) {
newList = newList.filter(t -> !t._1.equals(key));
newList = newList.filter(t -> !Objects.equals(t._1, key));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We called t._1.equals(...) where t._1 potentially could be null.

@@ -449,7 +449,7 @@ public boolean isEmpty() {
@Override
public LinkedHashMap<K, V> remove(K key) {
if (containsKey(key)) {
final Queue<Tuple2<K, V>> newList = list.removeFirst(t -> t._1.equals(key));
final Queue<Tuple2<K, V>> newList = list.removeFirst(t -> Objects.equals(t._1, key));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

dito

assertThat(Option.some(null)).isEqualTo(Option.when(true, () -> null));
assertThat(Option.some(null)).isEqualTo(Option.when(true, (Object) null));
assertThat(Option.when(true, () -> null)).isEqualTo(Option.some(null));
assertThat(Option.when(true, (Object) null)).isEqualTo(Option.some(null));
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 OptionTest the actual and expected values were confused in multiple assertions

@danieldietrich danieldietrich merged commit cbf0ed7 into vavr-io:master Oct 1, 2016
@danieldietrich danieldietrich deleted the null-keys branch October 3, 2016 01:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant