the difference is that in the original code, the most common path would be invoking both:
 - containsKey
 - put

the new one just invokes:
 - put

and verifies the (very unlikely) opposite case, so you are still getting the exception if there is something wrong going on.