Current implementation of HandlerContainer class has several issues:
- It uses the Subscription class in untyped fashion, ignoring its type parameter.
- .unsubscribe() method manually checks for all possible types of the subscription token, even though it is always known at the subscription time. This is error-prone and hard to read.
- When registering handlers, we use a sequence of two operations - Map.putIfAbsent() and .replace(), instead of just .put(). It also introduces a potential race condition, since the map is synchronized.