JENKINS-15380. Add some length checking before trying to substring.
Compare string length directly in if to get a shorter method.
Merge pull request #645 from thesam/issue15380

[FIXED JENKINS-15380]. Add some length checking before trying to substring names in ClassResult.