use entrySet instead of Keyset to improve performance.

Issue: SPR-12356
Merge remote-tracking branch 'origin/spr12356' into spr12356