HoustonPutman commented on a change in pull request #153: Fix issues reported 
by findbugs
URL: https://github.com/apache/lucene-solr/pull/153#discussion_r351399593
 
 

 ##########
 File path: 
solr/contrib/analytics/src/java/org/apache/solr/analytics/util/MedianCalculator.java
 ##########
 @@ -35,7 +35,9 @@
     select(list, .5 * size, 0, size);
 
     int firstIdx = (int) (Math.floor(.5 * size));
-    int secondIdx = (firstIdx <= size && size % 2 == 1) ? firstIdx + 1 : 
firstIdx;
+    // from findbug bug info: 
+    // The code uses x % 2 == 1 to check to see if a value is odd, but this 
won't work for negative numbers (e.g., (-5) % 2 == -1). If this code is 
intending to check for oddness, consider using x & 1 == 1, or x % 2 != 0. 
+    int secondIdx = (firstIdx <= size && size % 2 != 0) ? firstIdx + 1 : 
firstIdx;
 
 Review comment:
   This is a no-op since size is guaranteed to be non-negative. Also this 
analytics code is extremely out of date, and has pretty much all been 
re-written since this PR.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to