Fix potential NPE on exception path

Findbug reported NP_NULL_ON_SOME_PATH_EXCEPTION, Priority: Normal
Merge pull request #899 from mvach/potential-npe

Fix potential NPE on exception path