Apache Lucene open-source search software
SOLR-539: Fix for non-atomic long counters and a cast fix to avoid divide by zero
Otis Gospodnetic15fb1cd0cf2d
diff --git a/CHANGES.txt b/CHANGES.txtindex 09003279818..4c717c599f4 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -404,6 +404,9 @@ Bug Fixesbeen added for people who have come to depend on the existingbroken behavior. (hossman)+30. SOLR-539: Fix for non-atomic long counters and a cast fix to avoid divide+ by zero. (Sean Timm via Otis Gospodnetic)+Other Changes1. SOLR-135: Moved common classes to org.apache.solr.common and altered thebuild scripts to make two jars: apache-solr-1.3.jar anddiff --git a/src/java/org/apache/solr/handler/RequestHandlerBase.java b/src/java/org/apache/solr/handler/RequestHandlerBase.javaindex 10d5ed737a9..18c17504b6b 100644--- a/src/java/org/apache/solr/handler/RequestHandlerBase.java+++ b/src/java/org/apache/solr/handler/RequestHandlerBase.java@@ -39,13 +39,13 @@ public abstract class RequestHandlerBase implements SolrRequestHandler, SolrInfo// statistics// TODO: should we bother synchronizing these, or is an off-by-one error// acceptable every million requests or so?- long numRequests;- long numErrors;+ volatile long numRequests;+ volatile long numErrors;protected NamedList initArgs = null;protected SolrParams defaults;protected SolrParams appends;protected SolrParams invariants;- long totalTime = 0;+ volatile long totalTime = 0;long handlerStart = System.currentTimeMillis();/** shorten the class references for utilities */@@ -159,7 +159,7 @@ public abstract class RequestHandlerBase implements SolrRequestHandler, SolrInfolst.add("requests", numRequests);lst.add("errors", numErrors);lst.add("avgTimePerRequest", (float) totalTime / (float) this.numRequests);- lst.add("avgRequestsPerSecond", (float) numRequests*1000 / ((float)System.currentTimeMillis()-handlerStart));+ lst.add("avgRequestsPerSecond", (float) numRequests*1000 / (float)(System.currentTimeMillis()-handlerStart));return lst;}