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

#4851 ConcurrentHashSet→Utils.concurrentHashSet #4852

Merged
merged 5 commits into from
Sep 14, 2023

Conversation

magicprinc
Copy link
Contributor

Issue: #4851

It seems that io.vertx.core.impl.ConcurrentHashSet is a copy of JDK's Collections.newSetFromMap.
The Best Code is No Code At All.
It is probably a good idea to review and replace this class with two utility methods.

Copy link
Contributor

@tsegismont tsegismont left a comment

Choose a reason for hiding this comment

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

Thank you @magicprinc

Can you please make a few changes?

src/main/java/io/vertx/core/impl/ConcurrentHashSet.java Outdated Show resolved Hide resolved
src/main/java/io/vertx/core/impl/Utils.java Outdated Show resolved Hide resolved
src/test/java/io/vertx/core/ComplexHATest.java Outdated Show resolved Hide resolved
@magicprinc
Copy link
Contributor Author

magicprinc commented Sep 11, 2023

@tsegismont fixed. Please see.

Changed implementation to

public static <E> Set<E> concurrentHashSet (){
  return ConcurrentHashMap.newKeySet();// we can change implementation
}

or do you mean: replace everywhere Util.concurrentHashSet with its body?

I think this separate method is a more robust and readable solution.

@magicprinc
Copy link
Contributor Author

@He-Pin Could you fix other Vert.x modules (if any) which are using this - deleted - class

@He-Pin
Copy link
Contributor

He-Pin commented Sep 11, 2023

@magicprinc Hi, thanks for the ping, I think it would be better for you to do it, and I don't have a write access to this project, then I have to make a PR to yours and that will make the thing a little complicated :)

@magicprinc
Copy link
Contributor Author

@He-Pin @tsegismont I can't find any other ConcurrentHashSet usages besides the corrected ones, so we probably have managed it :-)

@tsegismont
Copy link
Contributor

@magicprinc before we merge this PR we also need updates for the projects that depend on this class (see #4851 (comment))

Utils.concurrentHashSet() → ConcurrentHashMap.newKeySet()
@magicprinc
Copy link
Contributor Author

@tsegismont All your tasks are done! 👍

  1. I have replaced method with its body.
  2. Fix in vertx-service-discovery: #4851 ConcurrentHashSet is redundant with ConcurrentHashMap#newKeySet() vert-x3/vertx-service-discovery#172
  3. Fix in vertx-mqtt: ConcurrentHashSet is redundant with ConcurrentHashMap#newKeySet() #4851 vert-x3/vertx-mqtt#243

Copy link
Contributor

@tsegismont tsegismont left a comment

Choose a reason for hiding this comment

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

@magicprinc one last comment, thank you

src/main/java/io/vertx/core/impl/DeploymentManager.java Outdated Show resolved Hide resolved
@magicprinc
Copy link
Contributor Author

magicprinc commented Sep 14, 2023

@He-Pin Could you review and approve this too? 🙏

Copy link
Contributor

@He-Pin He-Pin left a comment

Choose a reason for hiding this comment

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

Lgtm

@tsegismont tsegismont merged commit 7763104 into eclipse-vertx:master Sep 14, 2023
6 checks passed
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.

3 participants