You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2019/11/27 16:53:27 UTC

[GitHub] [lucene-solr] HoustonPutman commented on a change in pull request #153: Fix issues reported by findbugs

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:
users@infra.apache.org


With regards,
Apache Git Services

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