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

Add support unit tests for ConcurrentHashSet, #1117 #1128

Merged
merged 5 commits into from
Feb 15, 2025

Conversation

paulirwin
Copy link
Contributor

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a change, please open an issue to discuss the change or find an existing issue.

Add support unit tests for ConcurrentHashSet

Fixes #1117

Description

This ports tests from Harmony for Collections.synchronizedSet and ConcurrentHashMap and adapts them to our ConcurrentHashSet.

This also adds nullable reference type checking to ConcurrentHashSet, which exposed some nullability issues. Given that our current use of this type is for values that should never be null (or would otherwise throw an NRE upon use as null is not checked-for), this adds a generic type constraint of notnull to ensure that it cannot be used with nullable reference types. Work would need to be done (under proper unit test coverage) to make this null-friendly if that is needed in the future.

@paulirwin paulirwin added the notes:improvement An enhancement to an existing feature label Feb 11, 2025
Copy link
Contributor

@NightOwl888 NightOwl888 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR.

I have been considering phasing out the SystemTypesHelpers class (or at least most of the extension methods in it), so ideally any new tests we add would not have any dependencies on those extension methods (.add(), .contains(), .size(), etc.).

If we do keep them, they will definitely need a review. Some of the methods perform poorly or have better alternatives (.toString(), removeAll(), retainAll(), and ToByteArray() to name a few). The .append() overloads are generally there to allow culture invariant numbers to be appended, since .NET doesn't have that built-in. However, I am adding optional parameters to allow passing format and IFormatProvider on OpenStringBuilder in J2N. So, we should probably hold off on the review/removal of SystemTypesHelpers until after J2N has a build with OpenStringBuilder where those can be replaced directly by swapping in OpenStringBuilder for StringBuilder.

src/Lucene.Net/Support/ConcurrentHashSet.cs Outdated Show resolved Hide resolved
src/Lucene.Net.Tests/Support/TestConcurrentHashSet.cs Outdated Show resolved Hide resolved
src/Lucene.Net.Tests/Support/TestConcurrentHashSet.cs Outdated Show resolved Hide resolved
src/Lucene.Net.Tests/Support/TestConcurrentHashSet.cs Outdated Show resolved Hide resolved
src/Lucene.Net.Tests/Support/TestConcurrentHashSet.cs Outdated Show resolved Hide resolved
src/Lucene.Net.Tests/Support/TestConcurrentHashSet.cs Outdated Show resolved Hide resolved
src/Lucene.Net.Tests/Support/TestConcurrentHashSet.cs Outdated Show resolved Hide resolved
src/Lucene.Net.Tests/Support/TestConcurrentHashSet.cs Outdated Show resolved Hide resolved
src/Lucene.Net.Tests/Support/TestConcurrentHashSet.cs Outdated Show resolved Hide resolved
src/Lucene.Net.Tests/Support/TestConcurrentHashSet.cs Outdated Show resolved Hide resolved
@paulirwin paulirwin merged commit 6b161d9 into apache:master Feb 15, 2025
275 checks passed
@paulirwin paulirwin deleted the issue/1117 branch February 15, 2025 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notes:improvement An enhancement to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Support unit tests for ConcurrentHashSet
2 participants