fix a potential NPE found by FindBugs
Fix DMI_RANDOM_USED_ONLY_ONCE from findbugs