Fix deadlock by moving `res.get` outside of synchronized block.

Fixed #1002275.
Merge pull request #817 from dragos/issue/fix-deadlock-1002275

Fix deadlock by moving `res.get` outside of synchronized block.