Fix possible NPE when renaming tmp dir.
Merge pull request #1328 from jburel/npe-submit-failure

Fix possible NPE