Fix concurrent crash on HierarchicalObjectRepository 

@clebert, read also the added javadoc to the lock justifying the decisions. Feel free to close it if we need to discuss this more.

Notice that just making 'matches' a ConcurrentHashMap does not solve it.

We could have a race between the state of matches and the cache:
Thread1: addMatch(): i. clean cache; ii. add match to Map
Thread2: could add an (outdated) entry to the cache between 'i. clean cache' and
'ii. add match to Map'.