Tweaked MessageCache locks to handle exceptions better.

Change-Id: I3066d8dbebc97abcc0567d71625f995d62549b4c