pulsar icon indicating copy to clipboard operation
pulsar copied to clipboard

[improve][broker] Replace all ConcurrentOpenHashMap with the official ConcurrentHashMap in JDK

Open BewareMyPower opened this issue 1 year ago • 2 comments

Motivation

See https://github.com/apache/pulsar/issues/23215

Modifications

For broker related modules, including pulsar-broker, pulsar-websocket, managed-ledger,

  • Replace all ConcurrentOpenHashMap<T> with ConcurrentHashMap<T>
  • Replace all ConcurrentOpenHashSet<T> fields with ConcurrentHashMap<T, Boolean>
  • Replace unnecessary reflections in tests
  • Remove ConcurrentOpenHashSet since it's never used now

Documentation

  • [ ] doc
  • [ ] doc-required
  • [x] doc-not-needed
  • [ ] doc-complete

Matching PR in forked repository

PR in forked repository: https://github.com/BewareMyPower/pulsar/pull/34

BewareMyPower avatar Aug 24 '24 07:08 BewareMyPower

Hi, the change looks make sense. For ConcurrentOpenHashSet, how about replacing type declarations with Set and use ConcurrentHashMap.newKeySet() ?

To express the Set type, it's more straightforward than ConcurrentHashMap<T, Boolean> and helps the reader IMO.

ocadaruma avatar Aug 24 '24 23:08 ocadaruma

declarations with Set and use ConcurrentHashMap.newKeySet() ?

Good suggestion. I will adopt this suggestion.

BTW, I will split this PR into multiple parts because of there are many changes. So let me mark it drafted now and push more PRs.

BewareMyPower avatar Aug 25 '24 07:08 BewareMyPower

Closing since the changes have been made in other PRs.

lhotari avatar Oct 09 '24 13:10 lhotari