SCANNER-2172: Avoid hash collisions
Branch: issue/SCANNER-2172-avoid-collisions
Branch: master
Merged
Merged pull request
Merged in issue/SCANNER-2172-avoid-collisions (pull request #78)
- 291541f
- Author: Olli Nevalainen
- Closed by: Olli Nevalainen
- 2019-06-17
Description
System.identityHashCode
is not guaranteed to be unique although in practise it almost always is.
I considered using IdentityHashMap
but I would have had to make it synchronised as I believe this code is potentially called from multiple threads and Hashtable
was synchronised too.
I don’t see how OsgiServiceFactoryBean
could ever lose reference to the bean so there should be no need to make the key a WeakReference
. I’m not opposed to doing that just in case if anyone thinks that would be better.
@Jonathan Doklovic It’s been 6 years since you committed this code so I understand if you don’t remember anything about it, but I mentioned you just in case you do.