Avoid NPE when getting CodeSource

CodeSource can be null - add a check to avoid NPE
Merge pull request #130 from ash2k/avoid-npe

Avoid NPE when getting CodeSource