linkedin/norbert — pull request #78 by abhinigam (2014-12-15 18:46:38+00:00)
Title: Re-fixing the bug with an added test case.

For Each JMX value we add we maintain our own registry to avoid collisions in case of some race conditions where one thread is trying to un-register and another is trying to register.
There are two bugs which are being fixed here:
a) We were not correctly adding to the map and it was remaining empty due to a typo.
b) The second case is a little more complex:
I. Suppose one thread adds "hello world" mbean. The map will then contain "hello world" -> 0. The name used would be "hello world".
II. Another thread due to a race condition then adds another mbean. The map will then contain "hello world" -> 1. The name used by the second thread will be "hello world-1".
III. Now if the second mbean ("hello world-1") is unregistered. The map now does not contain any entry for "hello world".
IV. Should a thread try to register this mbean ("hello world") it will receive an error because the mbean created in step I still exists.