Division by zero in StatsComponent with date field always missing -----------------------------------------------------------------
Key: SOLR-3160 URL: https://issues.apache.org/jira/browse/SOLR-3160 Project: Solr Issue Type: Bug Affects Versions: 3.5 Reporter: Luca Cavanna Assignee: Luca Cavanna Priority: Minor Fix For: 3.6, 4.0 Using the StatsComponent with a date field that never has a value you'll get {code} java.lang.ArithmeticException: / by zero at org.apache.solr.handler.component.DateStatsValues.addTypeSpecificStats (StatsValuesFactory.java:384) {code} The problem is in this line of DateStatsValues: {code} res.add("mean", new Date(sum / count)); {code} If count is 0 the division throws ArithmeticException because sum is long here. This doesn't happen with NumericStatsValues because sum is double there and the division result is Nan. By the way, the result of those divisions is not even included in the output when count is 0 because of this condition in SimpleStats#getStatsFields: {code} if (isShard == true || (Long) stv.get("count") > 0) { res.add(f, stv); } else { res.add(f, null); } {code} Therefore, it should never throw an exception! -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org