You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kylin.apache.org by GitBox <gi...@apache.org> on 2018/11/12 00:59:22 UTC

[GitHub] shaofengshi closed pull request #326: KYLIN-3597, fix the critical bug reported by sonar: Make sure this ex…

shaofengshi closed pull request #326: KYLIN-3597, fix the critical bug reported by sonar: Make sure this ex…
URL: https://github.com/apache/kylin/pull/326
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/cache/src/main/java/net/spy/memcached/RefinedKetamaNodeLocator.java b/cache/src/main/java/net/spy/memcached/RefinedKetamaNodeLocator.java
index 95298d73e5..43f31bccc4 100644
--- a/cache/src/main/java/net/spy/memcached/RefinedKetamaNodeLocator.java
+++ b/cache/src/main/java/net/spy/memcached/RefinedKetamaNodeLocator.java
@@ -110,7 +110,7 @@ public RefinedKetamaNodeLocator(List<MemcachedNode> nodes, HashAlgorithm alg, Ke
      *          continuum
      * @param alg The hash algorithm to use when choosing a node in the Ketama
      *          consistent hash continuum
-     * @param weights node weights for ketama, a map from InetSocketAddress to
+     * @param nodeWeights node weights for ketama, a map from InetSocketAddress to
      *          weight as Integer
      * @param configuration node locator configuration
      */
@@ -233,7 +233,7 @@ protected void setKetamaNodes(List<MemcachedNode> nodes) {
             if (isWeightedKetama) {
 
                 int thisWeight = weights.get(node.getSocketAddress());
-                float percent = (float) thisWeight / (float) totalWeight;
+                float percent = (totalWeight == 0 ? 0f : (float) thisWeight / (float) totalWeight);
                 int pointerPerServer = (int) ((Math.floor(
                         (float) (percent * (float) config.getNodeRepetitions() / 4 * (float) nodeCount + 0.0000000001)))
                         * 4);


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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