Skip to content

Fix NPE in ordered-set #74

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

Merged
merged 1 commit into from
May 10, 2024
Merged

Conversation

NoahTheDuke
Copy link
Contributor

I fixed the existing flatland.ordered.set-test/nil-hash-code-npe test as it was incorrectly written and never actually checked that ordered sets can contain nulls. Oops!

Closes #73

Copy link
Contributor

@jafingerhut jafingerhut left a comment

Choose a reason for hiding this comment

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

LGTM

@NoahTheDuke NoahTheDuke merged commit b4277db into clj-commons:master May 10, 2024
@NoahTheDuke NoahTheDuke deleted the nb/fix-set-npe branch May 10, 2024 17:35
@@ -56,7 +56,7 @@
(toString [this]
(str "#{" (clojure.string/join " " (map str this)) "}"))
(hashCode [this]
(reduce + (map #(.hashCode ^Object %) (.seq this))))
(reduce + (keep #(when % (.hashCode ^Object %)) (.seq this))))
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't look good to me, since false will be treated the same way here as nil

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch. Highly recomended to add an explicit test case with false as an element of a set, to confirm, and then fix the expected issue that such a test case should find.

NoahTheDuke added a commit that referenced this pull request May 10, 2024
Fast-follow to #74 Fix NPE in ordered sets
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.

OrderedSet/hashCode throws an NPE if it contains nil
3 participants