ThreadLocal
is a common cause of memory leaks in JVMs.
In this post, we take a look under the hood to better understand what's going on.
Some background info, first. We have a superhero Wiki site with two portals in it: Batman and Superman.
public enum SuperheroPortal { BATMAN, SUPERMAN; }
Everything in the service layer depends on the currently selected portal.