div by null in word distance calculation

(again, description in http://mantis.tokeek.de/view.php?id=698)
as root cause was not seen, added just workaround reducing in favour over a 
try catch (for easier followup).
pull/88/head
reger 8 years ago
parent 7263d17436
commit 68217465fe

@ -126,7 +126,9 @@ public abstract class AbstractReference implements Reference {
if (s0 > 0) d += Math.abs(s0 - s1);
s0 = s1;
}
return d / (positions().size() - 1);
// despite first line checks for size < 2 Arithmetic exception div by zero occured (1.91/9278 2016-10-19)
// added d == 0 condition as protection for this (which was in all above tests the case)
return d == 0 ? 0 : d / (positions().size() - 1);
}
@Override

Loading…
Cancel
Save