kylin-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (KYLIN-3597) Fix sonar reported static code issues
Date Mon, 12 Nov 2018 01:00:00 GMT

    [ https://issues.apache.org/jira/browse/KYLIN-3597?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16683095#comment-16683095
] 

ASF GitHub Bot commented on KYLIN-3597:
---------------------------------------

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


> Fix sonar reported static code issues
> -------------------------------------
>
>                 Key: KYLIN-3597
>                 URL: https://issues.apache.org/jira/browse/KYLIN-3597
>             Project: Kylin
>          Issue Type: Improvement
>          Components: Others
>            Reporter: Shaofeng SHI
>            Priority: Major
>             Fix For: v2.6.0
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message