Lost a bunch of time just trying to figure out what was going on here, but I think I'm finally onto something.
We have some fairly normal PicoContainer code which simply turns on caching, which I thought was supposed to result in singleton behaviour:
container.as(Characteristics.CACHE).addComponent(Service.class, ServiceImpl.class);
However as we found today, we have a component which is apparently being constructed not once, but four times. It's not something I can reproduce on my own computer, just on some other developer machines.
We investigated further, and it turns out that multiple threads were hitting PicoContainer to look up the same component at the same time, and instead of instantiating one copy and making the other three threads wait, it appears that it just instantiates four copies (and then only remembers to keep around one of them.)
Is there some relatively simple way to get true singular behaviour in PicoContainer?