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

 ##########
 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:
   @HoustonPutman have a look at this. I'll not merge this PR but perhaps you 
like to fix this one bug in a separate commit?

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to