Add synchronisation around map `getOrElse`.

Needed for proper visibility, in case this code
is called on different threads.
(cherry picked from commit 6181d7f57da6c28cc6f6ef0df873a2f7a960ba73)
Merge pull request #612 from dragos/issue/add-sync-caching-jars

Add synchronisation around map `getOrElse`.