Fixed out of bounds exception

This commit is contained in:
2021-01-09 18:32:31 +01:00
parent 4c56f2c0ab
commit b5d18c63ce

View File

@@ -200,7 +200,7 @@ public class VotingController {
voteForPosCandidates.add(p); voteForPosCandidates.add(p);
} else { } else {
if(index > 31 && posCandidate.getName().indexOf(" ") != -1){ if(index > 31 && posCandidate.getName().indexOf(" ") != -1){
posCandidate.setName(posCandidate.getName().split(" ")[1]); posCandidate.setName(posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1]);
} }
PossibleCandidate possibleCandidate = new PossibleCandidate(posCandidate.getName(), categoryRepository.findById(index).get()); PossibleCandidate possibleCandidate = new PossibleCandidate(posCandidate.getName(), categoryRepository.findById(index).get());
addToPosCandidates.add(possibleCandidate); addToPosCandidates.add(possibleCandidate);