From 4c67ed3f8d82ab13d3960f493fb1efed610f1625 Mon Sep 17 00:00:00 2001 From: reger Date: Sat, 22 Oct 2016 00:53:47 +0200 Subject: [PATCH] catch rwi ranking div by zero exception during rwi search result processing worddistance calculation is effected by concurrent update (normalization) of min/max ranking parameter for wordpositions. On update of min/max the exception is raised in distance calc and now catched. This concurrent update and change of ranking results is needed for speed but should be further checked for optimization --- source/net/yacy/kelondro/rwi/AbstractReference.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/net/yacy/kelondro/rwi/AbstractReference.java b/source/net/yacy/kelondro/rwi/AbstractReference.java index 4417159d0..d972b4e29 100644 --- a/source/net/yacy/kelondro/rwi/AbstractReference.java +++ b/source/net/yacy/kelondro/rwi/AbstractReference.java @@ -28,6 +28,7 @@ package net.yacy.kelondro.rwi; import java.util.Collection; import java.util.Iterator; +import net.yacy.cora.util.ConcurrentLog; public abstract class AbstractReference implements Reference { @@ -128,7 +129,15 @@ public abstract class AbstractReference implements Reference { } // 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); + try { + return d == 0 ? 0 : d / (positions().size() - 1); + } catch (ArithmeticException ex) { + // TODO: in peer to peer normalization of rwi queue modifies concurrently positions resulting in div by 0 exception + // with effect of above check position() < 2 is false but now true, it also results in changing ranking results until normalization is finished + // see related/causing code ReferenceOrder.normalizewith() and WordReferenceVars.max()/WordReferenceVars.min() -> refacturing of posintext, distance, min, max needed + ConcurrentLog.fine("AbstractReference", "word distance calculation:" + ex.getMessage()); + return 0; + } } @Override