Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

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).

reger68217465fe9a
diff --git a/source/net/yacy/kelondro/rwi/AbstractReference.java b/source/net/yacy/kelondro/rwi/AbstractReference.java
index c2175becf..4417159d0 100644
--- a/source/net/yacy/kelondro/rwi/AbstractReference.java
+++ b/source/net/yacy/kelondro/rwi/AbstractReference.java
@@ -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