Fixed getPolicy() method to make it thread-safe.
Merge pull request #2474 from akarsakov:fix_getpolicy