Not sure if there is a risk of deadlock in the specific case, but could we use a concurrent data structure? (as it looks like all you need is ``putIfAbsent`` and ``get``) The only question for me is how do you get correct equality on ``WeakReference`` instances...